Created
November 6, 2012 12:00
-
-
Save alamboley/4024256 to your computer and use it in GitHub Desktop.
Revisions
-
alamboley revised this gist
Dec 14, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ public function Main() { levelManager = new LevelManager(ALevel); levelManager.applicationDomain = ApplicationDomain.currentDomain; // to be able to load your SWF level on iOS levelManager.onLevelChanged.add(_onLevelChanged); levelManager.levels = [[Level1, "levels/A1/LevelA1.swf"], [Level2, "levels/A2/LevelA2.swf"]]; levelManager.gotoLevel(); //load the first level, you can change the index. You can also call it later. -
alamboley revised this gist
Nov 13, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ public function Main() { levelManager = new LevelManager(ALevel); levelManager.onLevelChanged.add(_onLevelChanged); levelManager.levels = [[Level1, "levels/A1/LevelA1.swf"], [Level2, "levels/A2/LevelA2.swf"]]; levelManager.gotoLevel(); //load the first level, you can change the index. You can also call it later. } private function _onLevelChanged(lvl:ALevel):void { -
alamboley revised this gist
Nov 13, 2012 . 1 changed file with 30 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,33 @@ private function _restartLevel():void { state = levelManager.currentLevel as IState; } // Note that you must create an abstract class : Level1 and Level2 extends ALevel // which extends the State or StarlingState class. From our example : public class ALevel extends State { public var lvlEnded:Signal; public var restartLevel:Signal; protected var _level:MovieClip; public function ALevel(level:MovieClip = null) { super(); _level = level; lvlEnded = new Signal(); restartLevel = new Signal(); // Useful for not forgetting to import object from the Level Editor var objectsUsed:Array = [Hero, Platform, Enemy, Sensor, CitrusSprite]; } override public function initialize():void { super.initialize(); var box2d:Box2D = new Box2D("Box2D"); add(box2d); // create objects from our level made with Flash Pro ObjectMaker2D.FromMovieClip(_level); } } -
alamboley created this gist
Nov 6, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ //In your Main class : public function Main() { levelManager = new LevelManager(ALevel); levelManager.onLevelChanged.add(_onLevelChanged); levelManager.levels = [[Level1, "levels/A1/LevelA1.swf"], [Level2, "levels/A2/LevelA2.swf"]]; levelManager.gotoLevel(); } private function _onLevelChanged(lvl:ALevel):void { state = lvl; lvl.lvlEnded.add(_nextLevel); lvl.restartLevel.add(_restartLevel); } private function _nextLevel():void { levelManager.nextLevel(); } private function _restartLevel():void { state = levelManager.currentLevel as IState; } //Note that you should create an abstract clas : Level1 and Level2 extends ALevel which extends the State class.