Created
November 7, 2012 09:44
-
-
Save alamboley/4030440 to your computer and use it in GitHub Desktop.
How to change or destroy State (Citrus Engine recipe)
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 characters
// In the Main class : | |
public function Main() { | |
state = new TiledMapGameState(); | |
setTimeout(otherState, 4000); | |
} | |
private function otherState():void { | |
state = new AnOtherState(); | |
} | |
// When you create a new state the previous one is automatically destroyed and garbage collected. | |
// Obviously you can destroy a state without associate a new one thanks to the destroy method : | |
state.destroy(); | |
// You can also restart or change a state from a State class : | |
private function _restartLevel(cEvt:b2Contact):void { | |
CitrusEngine.getInstance().state = new FlipperState(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good