Last active
December 20, 2015 20:19
-
-
Save schonstal/6189985 to your computer and use it in GitHub Desktop.
how to pause
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
| var pauseGroup:PauseGroup; | |
| var paused:Boolean = false; | |
| public override function create():void { | |
| //your normal create | |
| pauseGroup = new PauseGroup(); | |
| } | |
| public override function update():void { | |
| if(FlxG.keys.justPressed(MY_PAUSE_BUTTON)) { | |
| paused = !paused; | |
| } | |
| if(!paused) { | |
| updateLogic(); | |
| super.update(); | |
| } else { | |
| pauseGroup.update(); | |
| } | |
| } | |
| public override function draw():void { | |
| super.draw(); | |
| if(paused) pauseGroup.draw(); | |
| } | |
| private function updateLogic():void { | |
| //Your update goes here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment