Skip to content

Instantly share code, notes, and snippets.

@alamboley
Created November 7, 2012 09:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alamboley/4030440 to your computer and use it in GitHub Desktop.
Save alamboley/4030440 to your computer and use it in GitHub Desktop.
How to change or destroy State (Citrus Engine recipe)
// 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();
}
@slowtoe
Copy link

slowtoe commented Dec 6, 2013

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment