Guest User

Untitled

a guest
Nov 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.70 KB | None | 0 0
  1. package {
  2. //This class loads all of the assets.
  3. //Please refer to line 337 for the loadAssets() method. This is where I add the item to the stage.
  4. import Levels.Level_0;
  5. import Levels.TimeIsUpScreen;
  6.  
  7. import Scenes.SceneAwards;
  8.  
  9. import Scenes.SceneMain;
  10.  
  11. import Scenes.SceneSettings;
  12. import Scenes.SceneSplash;
  13.  
  14. import Sounds.GameSoundManager;
  15.  
  16. import characters.loading;
  17. import characters.boat;
  18.  
  19. import starling.core.Starling;
  20. import starling.display.DisplayObject;
  21. import starling.display.Image;
  22. import starling.display.Sprite;
  23. import starling.events.EnterFrameEvent;
  24. import starling.utils.AssetManager;
  25. import starling.events.Event;
  26.  
  27. import flash.filesystem.File;
  28. import utils.ProgressBar;
  29. import flash.display.Loader;
  30. import flash.display.LoaderInfo;
  31.  
  32. import treefortress.sound.SoundAS;
  33.  
  34. public class Assets extends Sprite {
  35.  
  36. public var screenWidthDetermined:int = Starling.current.nativeStage.stageWidth;
  37. public static var assets:AssetManager = new AssetManager ();
  38. private var _appDir:File = File.applicationDirectory;
  39. private var _splash:SceneSplash;
  40. private var _maineScene:SceneMain;
  41. private var _loadingImage:Image;
  42. private var _loadingAnimation:loading;
  43.  
  44. public function Assets() {
  45. this.addEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  46. }
  47.  
  48. private function onAddedToStage(event:Event):void
  49. {
  50.  
  51. if (screenWidthDetermined == 960 )
  52. {
  53. trace ("The screen size is: " + screenWidthDetermined);
  54. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  55.  
  56. assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
  57. assets.loadQueue (function (ratio1:Number):void {
  58. if (ratio1 == 1.0)
  59. {
  60. _loadingAnimation = new loading();
  61. _loadingAnimation.alignPivot("center","center");
  62. _loadingAnimation.scaleX = .60;
  63. _loadingAnimation.scaleY = .60;
  64. _loadingAnimation.x = stage.stageWidth/2 +65;
  65. _loadingAnimation.y = stage.stageHeight/2 -50;
  66. addChild(_loadingAnimation);
  67. //stage.addChild(_loading);
  68. trace("3x assets are loading now");
  69. assets.enqueue (_appDir.resolvePath ("assets/1x/"));
  70. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  71. assets.loadQueue(function(ratio2:Number):void
  72. {
  73. if(ratio2 ==1)
  74. {
  75. removeChild(_loadingAnimation);
  76. _loadingAnimation.dispose();
  77. _loadingAnimation = null;
  78. trace("Loading the other stuff!");
  79. loadAssets ();
  80. }
  81. });
  82. }
  83. });
  84. }
  85.  
  86. if (screenWidthDetermined == 1136)
  87. {
  88. trace ("The screen size is: " + screenWidthDetermined);
  89. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  90.  
  91. assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
  92. assets.loadQueue (function (ratio1:Number):void {
  93. if (ratio1 == 1.0)
  94. {
  95. _loadingAnimation = new loading();
  96. _loadingAnimation.alignPivot("center","center");
  97. _loadingAnimation.scaleX = .60;
  98. _loadingAnimation.scaleY = .60;
  99. _loadingAnimation.x = stage.stageWidth/2 +55;
  100. _loadingAnimation.y = stage.stageHeight/2 -50;
  101. addChild(_loadingAnimation);
  102. //stage.addChild(_loading);
  103. trace("3x assets are loading now");
  104. assets.enqueue (_appDir.resolvePath ("assets/1x/"));
  105. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  106. assets.loadQueue(function(ratio2:Number):void
  107. {
  108. if(ratio2 ==1)
  109. {
  110.  
  111. removeChild(_loadingAnimation);
  112. _loadingAnimation.dispose();
  113. _loadingAnimation = null;
  114. trace("Loading the other stuff!");
  115. loadAssets ();
  116. }
  117. });
  118. }
  119. });
  120. }
  121.  
  122. if (screenWidthDetermined == 1024)
  123. {
  124. trace ("The screen size is: " + screenWidthDetermined);
  125. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  126.  
  127. assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
  128. assets.loadQueue (function (ratio1:Number):void {
  129. if (ratio1 == 1.0)
  130. {
  131. _loadingAnimation = new loading();
  132. _loadingAnimation.alignPivot("center","center");
  133. _loadingAnimation.scaleX = .60;
  134. _loadingAnimation.scaleY = .60;
  135. _loadingAnimation.x = stage.stageWidth/2 +65;
  136. _loadingAnimation.y = stage.stageHeight/2 -50;
  137. addChild(_loadingAnimation);
  138. //stage.addChild(_loading);
  139. trace("3x assets are loading now");
  140. assets.enqueue (_appDir.resolvePath ("assets/1x/"));
  141. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  142. assets.loadQueue(function(ratio2:Number):void
  143. {
  144. if(ratio2 ==1)
  145. {
  146.  
  147. removeChild(_loadingAnimation);
  148. _loadingAnimation.dispose();
  149. _loadingAnimation = null;
  150. trace("Loading the other stuff!");
  151. loadAssets ();
  152. }
  153. });
  154. }
  155. });
  156.  
  157. }
  158.  
  159. if (screenWidthDetermined == 1334)
  160. {
  161. trace ("The screen size is: " + screenWidthDetermined);
  162. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  163.  
  164. assets.enqueue (_appDir.resolvePath ("assets/loading12x/"));
  165. assets.loadQueue (function (ratio1:Number):void {
  166. if (ratio1 == 1.0)
  167. {
  168. _loadingAnimation = new loading();
  169. _loadingAnimation.alignPivot("center","center");
  170. _loadingAnimation.scaleX = .60;
  171. _loadingAnimation.scaleY = .60;
  172. _loadingAnimation.x = stage.stageWidth/2 +65;
  173. _loadingAnimation.y = stage.stageHeight/2 -50;
  174. addChild(_loadingAnimation);
  175. //stage.addChild(_loading);
  176. trace("3x assets are loading now");
  177. assets.enqueue (_appDir.resolvePath ("assets/2x/"));
  178. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  179. assets.loadQueue(function(ratio2:Number):void
  180. {
  181. if(ratio2 ==1)
  182. {
  183. removeChild(_loadingAnimation);
  184. _loadingAnimation.dispose();
  185. _loadingAnimation = null;
  186. trace("Loading the other stuff!");
  187. loadAssets ();
  188. }
  189. });
  190. }
  191. });
  192.  
  193. }
  194.  
  195. if (screenWidthDetermined == 1920)
  196. {
  197. trace ("The screen size is: " + screenWidthDetermined);
  198. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  199.  
  200. assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
  201. assets.loadQueue (function (ratio1:Number):void {
  202. if (ratio1 == 1.0)
  203. {
  204. //load robot here
  205. _loadingAnimation = new loading();
  206. _loadingAnimation.alignPivot("center","center");
  207. _loadingAnimation.x = stage.stageWidth/2;
  208. _loadingAnimation.y = stage.stageHeight/2;
  209. addChild(_loadingAnimation);
  210.  
  211. assets.enqueue (_appDir.resolvePath ("assets/3x/"));
  212. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  213. assets.loadQueue(function(ratio2:Number):void
  214. {
  215. if(ratio2 ==1)
  216. {
  217. removeChild(_loadingAnimation);
  218. _loadingAnimation.dispose();
  219. _loadingAnimation = null;
  220.  
  221. trace("Loading the other stuff!");
  222. loadAssets ();
  223. }
  224. });
  225. }
  226. });
  227. }
  228. if (screenWidthDetermined == 2208)
  229. {
  230. trace ("The screen size is: " + screenWidthDetermined);
  231. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  232.  
  233. assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
  234. assets.loadQueue (function (ratio1:Number):void {
  235. if (ratio1 == 1.0)
  236. {
  237. _loadingAnimation = new loading();
  238. _loadingAnimation.alignPivot("center","center");
  239. _loadingAnimation.x = stage.stageWidth/2;
  240. _loadingAnimation.y = stage.stageHeight/2;
  241. addChild(_loadingAnimation);
  242. //stage.addChild(_loading);
  243. trace("3x assets are loading now");
  244. assets.enqueue (_appDir.resolvePath ("assets/3x/"));
  245. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  246. assets.loadQueue(function(ratio2:Number):void
  247. {
  248. if(ratio2 ==1)
  249. {
  250.  
  251. removeChild(_loadingAnimation);
  252. _loadingAnimation.dispose();
  253. _loadingAnimation = null;
  254. trace("Loading the other stuff!");
  255. loadAssets ();
  256. }
  257. });
  258. }
  259. });
  260.  
  261. }
  262.  
  263. if (screenWidthDetermined == 2048)
  264. {
  265. trace ("The screen size is: " + screenWidthDetermined);
  266. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  267.  
  268. assets.enqueue (_appDir.resolvePath ("assets/loading3x/"));
  269. assets.loadQueue (function (ratio1:Number):void {
  270. if (ratio1 == 1.0)
  271. {
  272. //load roobot here
  273. _loadingAnimation = new loading();
  274. _loadingAnimation.alignPivot("center","center");
  275. _loadingAnimation.x = stage.stageWidth/2;
  276. _loadingAnimation.y = stage.stageHeight/2;
  277. addChild(_loadingAnimation);
  278. //stage.addChild(_loading);
  279. trace("3x assets are loading now");
  280. assets.enqueue (_appDir.resolvePath ("assets/3x/"));
  281. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  282. assets.loadQueue(function(ratio2:Number):void
  283. {
  284. if(ratio2 ==1)
  285. {
  286. removeChild(_loadingAnimation);
  287. _loadingAnimation.dispose();
  288. _loadingAnimation = null;
  289. trace("Loading the other stuff!");
  290. loadAssets ();
  291. }
  292. });
  293. }
  294. });
  295.  
  296.  
  297. }
  298.  
  299. if (screenWidthDetermined == 2732)
  300. {
  301. trace ("The screen size is: " + screenWidthDetermined);
  302. this.removeEventListener (Event.ADDED_TO_STAGE, onAddedToStage);
  303.  
  304. assets.enqueue (_appDir.resolvePath ("assets/loading4x/"));
  305. assets.loadQueue (function (ratio1:Number):void {
  306. if (ratio1 == 1.0)
  307. {
  308. //load roobot here
  309. _loadingAnimation = new loading();
  310. _loadingAnimation.alignPivot("center","center");
  311. _loadingAnimation.x = stage.stageWidth/2;
  312. _loadingAnimation.y = stage.stageHeight/2;
  313. addChild(_loadingAnimation);
  314. //stage.addChild(_loading);
  315. trace("3x assets are loading now");
  316. assets.enqueue (_appDir.resolvePath ("assets/4x/"));
  317. assets.enqueue (_appDir.resolvePath ("assets/sounds/"));
  318. assets.loadQueue(function(ratio2:Number):void
  319. {
  320. if(ratio2 ==1)
  321. {
  322. removeChild(_loadingAnimation);
  323. trace("Loading the other stuff!");
  324. loadAssets ();
  325. }
  326. });
  327. }
  328. });
  329.  
  330.  
  331. }
  332.  
  333. }
  334.  
  335.  
  336.  
  337. private function loadAssets():void
  338. {
  339. _maineScene = new SceneMain();
  340. addChild(_maineScene);
  341. //addChild(_TempTimesUpScreen);
  342.  
  343. //_splash = new SceneSplash();
  344. //stage.addChild(_splash);
  345.  
  346. }
  347.  
  348. /*public function removeFromMainScene():void
  349. {
  350. trace("You clicked the play button.");
  351. this.visible = false;
  352. //removeChild(this);
  353. //if(_maineScene.contains(child)) {_maineScene.removeChild(child);}
  354. }*/
  355.  
  356.  
  357. //********************* End of class
  358. }
  359. //***********************************End of package
  360. }
Add Comment
Please, Sign In to add comment