-
-
Save anonymous/bd058d6ee1962564f9b76e37c11e6b97 to your computer and use it in GitHub Desktop.
This file contains 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.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