Skip to content

Instantly share code, notes, and snippets.

/Main.hx Secret

Created Mar 29, 2016
Embed
What would you like to do?
package;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.Lib;
import openfl.Assets;
class Main extends Sprite {
private var image: Bitmap;
private var previousTime: Int;
public function new () {
super();
image = new Bitmap(Assets.getBitmapData ("img/EasyToUse.png"));
addChild (image);
previousTime = Lib.getTimer ();
addEventListener (Event.ENTER_FRAME, this_onEnterFrame);
}
private function this_onEnterFrame (event:Event):Void {
var currentTime = Lib.getTimer ();
var deltaTime = currentTime - previousTime;
trace(deltaTime);
previousTime = currentTime;
image.x += 40 * (deltaTime / 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment