-
-
Save PrimaryFeather/e96da3a63ee646aba5af43f0d58d98a3 to your computer and use it in GitHub Desktop.
Minimal, self-contained Starling mobile app.
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.desktop.NativeApplication; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.geom.Rectangle; | |
import starling.core.Starling; | |
[SWF(width="320", height="480", frameRate="30", backgroundColor="#909090")] | |
public class MinimalMobileApp extends Sprite | |
{ | |
private var _starling:Starling; | |
public function MinimalMobileApp() | |
{ | |
var viewPort:Rectangle = new Rectangle(0, 0, | |
stage.fullScreenWidth, stage.fullScreenHeight); | |
_starling = new Starling(Root, stage, viewPort); | |
_starling.start(); | |
NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, onActivate); | |
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivate); | |
} | |
private function onActivate(e:*):void | |
{ | |
trace("Activate event received."); | |
_starling.start(); | |
} | |
private function onDeactivate(e:*):void | |
{ | |
trace("Deactivate event received."); | |
_starling.stop(true); | |
} | |
} | |
} | |
import starling.core.Starling; | |
import starling.display.Quad; | |
import starling.display.Sprite; | |
import starling.events.Event; | |
class Root extends Sprite | |
{ | |
public function Root() | |
{ | |
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
} | |
private function onAddedToStage():void | |
{ | |
var quad:Quad = new Quad(100, 100, 0xff0000); | |
quad.alignPivot(); | |
quad.x = stage.stageWidth / 2; | |
quad.y = stage.stageHeight / 2; | |
addChild(quad); | |
Starling.juggler.tween(quad, 5, { rotation: Math.PI * 2, repeatCount: 0 }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment