/** The aim of the game is to knock over all of the pins. When a pin is knocked over, it fades away. */ class Pin : Scenery { // Are we on a Play scene? (and not a DollsHouse scene). var isPlay = false override fun begin() { if ( Game.instance.director is Play ) { isPlay = true Play.instance.objectives ++ } } override fun tick() { // Check isFinished() to ensure that we only run this code when the pin is *first* knocked over. if ( isPlay && isFinished() && ( actor.direction.degrees < -70 || actor.direction.degrees > 70) ) { actor.event("score") Star.createRing( actor ) replaceAction( Fade(actor.color, 1.0, 0f, Eases.easeIn) thenOnce Play.instance:>objectiveComplete then Kill(actor) ) } // Must be AFTER tick, otherwise we may count this twice. super.tick() } }