Created
November 8, 2013 00:38
-
-
Save Draknek/7364426 to your computer and use it in GitHub Desktop.
FlashPunk Alarm example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package | |
| { | |
| import flash.events.TextEvent; | |
| import net.flashpunk.FP; | |
| import net.flashpunk.graphics.Text; | |
| import net.flashpunk.tweens.misc.Alarm; | |
| import net.flashpunk.World; | |
| public class SimpleWorld extends World | |
| { | |
| private var simpleAlarm:Alarm | |
| private var simpleText:Text; | |
| public function SimpleWorld() | |
| { | |
| simpleAlarm = new Alarm(1, randomizeText); | |
| addTween(simpleAlarm, true); // adds the tween to the world and starts it running | |
| simpleText = new Text("RANDOM", 0, 0); | |
| addGraphic(simpleText); | |
| } | |
| private function randomizeText():void | |
| { | |
| simpleText.x = FP.rand(FP.width); | |
| simpleText.y = FP.rand(FP.height); | |
| simpleAlarm.reset(1); | |
| } | |
| override public function update():void | |
| { | |
| super.update(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment