Skip to content

Instantly share code, notes, and snippets.

@ryzed
Created March 5, 2015 18:14
Show Gist options
  • Save ryzed/1dd3ffaae2471a2f7b8b to your computer and use it in GitHub Desktop.
Save ryzed/1dd3ffaae2471a2f7b8b to your computer and use it in GitHub Desktop.
openfl_html5_1 source
package;
import haxe.Timer;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.events.Event;
/**
* ...
* @author ryzed
*/
class Main extends Sprite
{
var spr:Sprite;
var lastTime:Float;
public function new()
{
super();
// Assets:
// openfl.Assets.getBitmapData("img/assetname.jpg");
spr = new Sprite();
var g = spr.graphics;
g.lineStyle(0, 0xffffff);
g.drawRect( -32, -32, 64, 64);
g.lineStyle(2, 0xff0000);
g.beginFill(0x00ff00);
g.drawCircle(32, 32, 8);
g.endFill();
spr.x = 200;
spr.y = 200;
this.addChild(spr);
lastTime = Timer.stamp();
this.addEventListener(Event.ENTER_FRAME, onFrame);
}
function onFrame(e:Event):Void
{
var curTime = Timer.stamp();
var dt = lastTime-curTime;
lastTime = curTime;
spr.rotation += (dt * 20);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment