Advertisement
Guest User

package

a guest
Jul 19th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.display.StageAlign;
  5. import flash.display.StageOrientation;
  6. import flash.display.StageScaleMode;
  7. import flash.events.Event;
  8. import flash.events.StageOrientationEvent;
  9.  
  10. import starling.core.Starling;
  11. import starling.display.Quad;
  12.  
  13. public class mobileTest extends Sprite
  14. {
  15.     private var myStarling:Starling;
  16.     public function mobileTest()
  17.     {
  18.         super();
  19.         stage.align = StageAlign.TOP_LEFT;
  20.         stage.scaleMode = StageScaleMode.NO_SCALE;
  21.         stage.addEventListener(flash.events.Event.RESIZE,onResize);
  22.     }
  23.  
  24.     private function onResize(e:flash.events.Event):void
  25.     {
  26.  
  27.         if (myStarling == null)
  28.         {
  29.             Starling.handleLostContext = true;
  30.             myStarling = new Starling(Main,stage);
  31.             myStarling.start();
  32.         }
  33.     }
  34. }
  35. }
  36.    
  37. package
  38. {
  39. import feathers.themes.AeonDesktopTheme;
  40.  
  41. import starling.core.Starling;
  42. import starling.display.Quad;
  43. import starling.display.Sprite;
  44. import starling.events.Event;
  45.  
  46. public class Main extends Sprite
  47. {
  48.     private var theme:AeonDesktopTheme;
  49.     public function Main()
  50.     {
  51.         super();
  52.         this.addEventListener(starling.events.Event.ADDED_TO_STAGE,addToStage);
  53.     }
  54.     private function addToStage(e:starling.events.Event):void
  55.     {
  56.         this.theme = new AeonDesktopTheme( this.stage );
  57.         var quad:Quad = new Quad(stage.stageHeight,stage.stageHeight,0xff0000);
  58.         addChild(quad);
  59.  
  60.     }
  61. }
  62. }
  63.    
  64. var viewPort:Rectangle = new Rectangle(0, 0, stage.fullScreenWidth,stage.fullScreenHeight);
  65. Starling.current.viewPort = viewPort;
  66.    
  67. Hi this is the code for StartUp file using starling. go through it and replace wtever u are missing.
  68.  
  69. package
  70. {
  71.     import flash.display.Sprite;
  72.     import flash.display.StageAlign;
  73.     import flash.display.StageScaleMode;
  74.     import flash.events.Event;
  75.     import flash.geom.Rectangle;
  76.     import flash.system.Capabilities;
  77.  
  78.     import starling.core.Starling;
  79.     import starling.events.TouchPhase;
  80.  
  81.     //[SWF(width="2048", height="1536", frameRate="60", backgroundColor="0x000000")]//ipad 4th generation Retina
  82.     //[SWF(width="1136", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 5th generation
  83.     //[SWF(width="1024", height="768", frameRate="60", backgroundColor="0x000000")]//ipad
  84.     //[SWF(width="960", height="640", frameRate="60", backgroundColor="0x000000")]//iphone 4th generation
  85.     [SWF(width="480", height="320", frameRate="60", backgroundColor="0x000000")] //iphone 3rd generation
  86.  
  87.     public class SuperBaby extends Sprite
  88.     {
  89.         private var mStarling:Starling;
  90.  
  91.         public function SuperBaby()
  92.         {
  93.             // set general properties
  94.  
  95.             stage.scaleMode = StageScaleMode.NO_SCALE;
  96.             stage.align = StageAlign.TOP_LEFT;
  97.  
  98.             Starling.multitouchEnabled = false;  // useful on mobile devices
  99.             Starling.handleLostContext = false; // not necessary on iOS. Saves a lot of memory!
  100.  
  101.             // create a suitable viewport for the screen size
  102.             var screenWidth:int  = stage.stageWidth;
  103.             var screenHeight:int = stage.stageHeight;
  104.             var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight);
  105.             var scaleFactor:uint;
  106.             if(screenHeight < 480){
  107.                 scaleFactor = 1;
  108.             }else if(screenHeight>=480){ //&& screenWidth<=640
  109.                 scaleFactor = 2;
  110.             }          
  111.  
  112.             // While Stage3D is initializing, the screen will be blank. To avoid any flickering,
  113.             // we display a startup image now and remove it below, when Starling is ready to go.
  114.  
  115.             // launch Starling
  116.             mStarling = new Starling(Mainmenu, stage, viewPort);
  117.             mStarling.simulateMultitouch  = false;
  118.             mStarling.enableErrorChecking = false;
  119.  
  120.  
  121.             Mainmenu.GAME_W=mStarling.stage.stageWidth  = uint(screenWidth/scaleFactor);
  122.             Mainmenu.GAME_H=mStarling.stage.stageHeight = uint(screenHeight/scaleFactor);
  123.  
  124.             mStarling.stage3D.addEventListener(Event.CONTEXT3D_CREATE, function(e:Event):void
  125.             {
  126.                 mStarling.start();
  127.             });
  128.  
  129.  
  130.  
  131.  
  132.             // When the game becomes inactive, we pause Starling; otherwise, the enter frame event
  133.             // would report a very long 'passedTime' when the app is reactivated.
  134.         }
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement