Skip to content

Instantly share code, notes, and snippets.

@Draknek
Created November 8, 2013 00:38
Show Gist options
  • Save Draknek/7364426 to your computer and use it in GitHub Desktop.
Save Draknek/7364426 to your computer and use it in GitHub Desktop.
FlashPunk Alarm example
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