/** Adds a bit of Christmas spirit. Creates snow flakes, which are governed by the physics engine. The initial Y position of the snow is the same as this. The X position is between this.actor.x and [toX]. */ class SnowMachine : ActionRole() { @Attribute( about="The maximum X value for the generated snow flakes" ) var toX = 1280 @Attribute( about="How quickly snow flakes are generated (units per second) " ) var period = 0.2 @Attribute( about="Total number of snow flakes to create" ) var count = 200 override fun createAction(): Action { return ( Delay(period) thenOnce this:>createSnow ).repeat( count ) } fun createSnow() { val snowA = actor.createChild("snow") snowA.x = Rand.between(actor.x, toX) snowA.y = actor.y } }