class ElasticPlayer : Player { @Attribute var strength = 10 @Attribute var max = 100 var elastic : Elastic val diff = Vector2() override fun begin() { val elasticA = actor.createChild( "elastic" ) elasticA.zOrder = actor.zOrder - 1 elastic = elasticA.role as Elastic elasticA.color.set( clan.color ) elasticA.color.alpha = 0.8 super.begin() } override fun followAction() : Action = this:>follow.action() fun follow() : bool { diff.setMinus( actor.position , elastic.actor.position ) val foo = diff.length() if ( foo > max ) { diff *= (max / foo) } diff *= ( strength / max ) actor.position -= diff elastic.pointTo(actor.position) return false } override fun die() { super.die() elastic.actor.die() } }