Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- //This class loads all of the assets.
- //Please refer to line 337 for the loadAssets() method. This is where I add the item to the stage.
- import Levels.Level_0;
- import Levels.TimeIsUpScreen;
- import Scenes.SceneAwards;
- import Scenes.SceneMain;
- import Scenes.SceneSettings;
- import Scenes.SceneSplash;
- import Sounds.GameSoundManager;
- import characters.loading;
- import characters.boat;
- import starling.core.Starling;
- import starling.display.DisplayObject;
- import starling.display.Image;
- import starling.display.Sprite;
- import starling.events.EnterFrameEvent;
- import starling.utils.AssetManager;
- import starling.events.Event;
- import flash.filesystem.File;
- import utils.ProgressBar;
- import flash.display.Loader;
- import flash.display.LoaderInfo;
- import treefortress.sound.SoundAS;
- public class Assets extends Sprite {
- public var screenWidthDetermined:int = Starling.current.nativeStage.stageWidth;
- public static var assets:AssetManager = new AssetManager ();
- private var _appDir:File = File.applicationDirectory;
- private var _splash:SceneSplash;
- private var _maineScene:SceneMain;
- private var _loadingImage:Image;
- private var _loadingAnimation:loading;
- public function Assets() {
- this.addEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- }
- private function onAddedToStage(event:Event):void
- {
- if (screenWidthDetermined == 960 )
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.scaleX = .60;
- _loadingAnimation.scaleY = .60;
- _loadingAnimation.x = stage.stageWidth/2 +65;
- _loadingAnimation.y = stage.stageHeight/2 -50;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/1x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 1136)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.scaleX = .60;
- _loadingAnimation.scaleY = .60;
- _loadingAnimation.x = stage.stageWidth/2 +55;
- _loadingAnimation.y = stage.stageHeight/2 -50;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/1x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 1024)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.scaleX = .60;
- _loadingAnimation.scaleY = .60;
- _loadingAnimation.x = stage.stageWidth/2 +65;
- _loadingAnimation.y = stage.stageHeight/2 -50;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/1x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 1334)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.scaleX = .60;
- _loadingAnimation.scaleY = .60;
- _loadingAnimation.x = stage.stageWidth/2 +65;
- _loadingAnimation.y = stage.stageHeight/2 -50;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/2x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 1920)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- //load robot here
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.x = stage.stageWidth/2;
- _loadingAnimation.y = stage.stageHeight/2;
- addChild(_loadingAnimation);
- assets.enqueue (_appDir.resolvePath ("assets/3x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 2208)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.x = stage.stageWidth/2;
- _loadingAnimation.y = stage.stageHeight/2;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/3x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 2048)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- //load roobot here
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.x = stage.stageWidth/2;
- _loadingAnimation.y = stage.stageHeight/2;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/3x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- _loadingAnimation.dispose();
- _loadingAnimation = null;
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- if (screenWidthDetermined == 2732)
- {
- trace ("The screen size is: " + screenWidthDetermined);
- this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
- assets.enqueue (_appDir.resolvePath ("assets/loading4x/"));
- assets.loadQueue (function (ratio1:Number):void {
- if (ratio1 == 1.0)
- {
- //load roobot here
- _loadingAnimation = new loading();
- _loadingAnimation.alignPivot("center","center");
- _loadingAnimation.x = stage.stageWidth/2;
- _loadingAnimation.y = stage.stageHeight/2;
- addChild(_loadingAnimation);
- //stage.addChild(_loading);
- trace("3x assets are loading now");
- assets.enqueue (_appDir.resolvePath ("assets/4x/"));
- assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
- assets.loadQueue(function(ratio2:Number):void
- {
- if(ratio2 ==1)
- {
- removeChild(_loadingAnimation);
- trace("Loading the other stuff!");
- loadAssets ();
- }
- });
- }
- });
- }
- }
- private function loadAssets():void
- {
- _maineScene = new SceneMain();
- addChild(_maineScene);
- //addChild(_TempTimesUpScreen);
- //_splash = new SceneSplash();
- //stage.addChild(_splash);
- }
- /*public function removeFromMainScene():void
- {
- trace("You clicked the play button.");
- this.visible = false;
- //removeChild(this);
- //if(_maineScene.contains(child)) {_maineScene.removeChild(child);}
- }*/
- //********************* End of class
- }
- //***********************************End of package
- }
Add Comment
Please, Sign In to add comment