Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageOrientation;
- import flash.display.StageScaleMode;
- import flash.events.Event;
- import flash.events.StageOrientationEvent;
- import starling.core.Starling;
- import starling.display.Quad;
- public class mobileTest extends Sprite
- {
- private var myStarling:Starling;
- public function mobileTest()
- {
- super();
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.addEventListener(flash.events.Event.RESIZE,onResize);
- }
- private function onResize(e:flash.events.Event):void
- {
- if (myStarling == null)
- {
- Starling.handleLostContext = true;
- myStarling = new Starling(Main,stage);
- myStarling.start();
- }
- }
- }
- }
- package
- {
- import feathers.themes.AeonDesktopTheme;
- import starling.core.Starling;
- import starling.display.Quad;
- import starling.display.Sprite;
- import starling.events.Event;
- public class Main extends Sprite
- {
- private var theme:AeonDesktopTheme;
- public function Main()
- {
- super();
- this.addEventListener(starling.events.Event.ADDED_TO_STAGE,addToStage);
- }
- private function addToStage(e:starling.events.Event):void
- {
- this.theme = new AeonDesktopTheme( this.stage );
- var quad:Quad = new Quad(stage.stageHeight,stage.stageHeight,0xff0000);
- addChild(quad);
- }
- }
- }
- var viewPort:Rectangle = new Rectangle(0, 0, stage.fullScreenWidth,stage.fullScreenHeight);
- Starling.current.viewPort = viewPort;
- Hi this is the code for StartUp file using starling. go through it and replace wtever u are missing.
- package
- {
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.events.Event;
- import flash.geom.Rectangle;
- import flash.system.Capabilities;
- import starling.core.Starling;
- import starling.events.TouchPhase;
- //[SWF(width="2048", height="1536", frameRate="60", backgroundColor="0x000000")]//ipad 4th generation Retina
- //[SWF(width="1136", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 5th generation
- //[SWF(width="1024", height="768", frameRate="60", backgroundColor="0x000000")]//ipad
- //[SWF(width="960", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 4th generation
- [SWF(width="480", height="320", frameRate="60", backgroundColor="0x000000")] //iphone 3rd generation
- public class SuperBaby extends Sprite
- {
- private var mStarling:Starling;
- public function SuperBaby()
- {
- // set general properties
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- Starling.multitouchEnabled = false; // useful on mobile devices
- Starling.handleLostContext = false; // not necessary on iOS. Saves a lot of memory!
- // create a suitable viewport for the screen size
- var screenWidth:int = stage.stageWidth;
- var screenHeight:int = stage.stageHeight;
- var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight);
- var scaleFactor:uint;
- if(screenHeight < 480){
- scaleFactor = 1;
- }else if(screenHeight>=480){ //&& screenWidth<=640
- scaleFactor = 2;
- }
- // While Stage3D is initializing, the screen will be blank. To avoid any flickering,
- // we display a startup image now and remove it below, when Starling is ready to go.
- // launch Starling
- mStarling = new Starling(Mainmenu, stage, viewPort);
- mStarling.simulateMultitouch = false;
- mStarling.enableErrorChecking = false;
- Mainmenu.GAME_W=mStarling.stage.stageWidth = uint(screenWidth/scaleFactor);
- Mainmenu.GAME_H=mStarling.stage.stageHeight = uint(screenHeight/scaleFactor);
- mStarling.stage3D.addEventListener(Event.CONTEXT3D_CREATE, function(e:Event):void
- {
- mStarling.start();
- });
- // When the game becomes inactive, we pause Starling; otherwise, the enter frame event
- // would report a very long 'passedTime' when the app is reactivated.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement