Created
September 11, 2015 20:12
-
-
Save an-OK-squirrel/fd7ac2e38dc346180642 to your computer and use it in GitHub Desktop.
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 openfl.display.Sprite; | |
class Ball extends Sprite { | |
public function new() { | |
super(); | |
this.graphics.beginFill(0xffffff); | |
this.graphics.drawCircle(0, 0, 10); | |
this.graphics.endFill(); | |
} | |
} |
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.display.Sprite; | |
import flash.events.Event; | |
import flash.Lib; | |
class Main extends Sprite | |
{ | |
var inited:Bool; | |
private var platform1:Platform; | |
private var platform2:Platform; | |
private var ball:Ball; | |
/* ENTRY POINT */ | |
function resize(e) | |
{ | |
if (!inited) init(); | |
// else (resize or orientation change) | |
} | |
function init() | |
{ | |
if (inited) return; | |
inited = true; | |
platform1 = new Platform(); | |
platform1.x = 5; | |
platform2.y = 200; | |
this.addChild(platform1); | |
platform2 = new Platform(); | |
platform1.x = 480; | |
platform2.y = 200; | |
this.addChild(platform2); | |
ball = new Ball(); | |
ball.x = 250; | |
ball.y = 250; | |
this.addChild(ball); | |
} | |
/* SETUP */ | |
public function new() | |
{ | |
super(); | |
addEventListener(Event.ADDED_TO_STAGE, added); | |
} | |
function added(e) | |
{ | |
removeEventListener(Event.ADDED_TO_STAGE, added); | |
stage.addEventListener(Event.RESIZE, resize); | |
#if ios | |
haxe.Timer.delay(init, 100); // iOS 6 | |
#else | |
init(); | |
#end | |
} | |
public static function main() | |
{ | |
// static entry point | |
Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT; | |
Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE; | |
Lib.current.addChild(new Main()); | |
// | |
} | |
} |
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 openfl.display.Sprite; | |
class Platform extends Sprite { | |
public function new() { | |
super(); | |
this.graphics.beginFill(0xffffff); | |
this.graphics.drawRect(0, 0, 15, 100); | |
this.graphics.endFill(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment