Skip to content

Instantly share code, notes, and snippets.

@jonahvsweb
Forked from alamboley/gist:4024256
Created January 29, 2013 05:24
Show Gist options
  • Select an option

  • Save jonahvsweb/4662025 to your computer and use it in GitHub Desktop.

Select an option

Save jonahvsweb/4662025 to your computer and use it in GitHub Desktop.
//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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment