Jump to content

implementing pause with tweens


defic
 Share

Recommended Posts

I want to be able to tween my pause menu when I hit pause, but it seems that if game.pause = true, tweens do not work anymore. My game is p2 physics based, and I got around the problem py using game.physics.p2.paused. All was fine, but now I am using timed events for kinematic objects, and it is not working properly anymore (as the time keeps running in the background while game is 'paused').

 

I have my timed events like this:

this.game.time.events.add(Phaser.Timer.SECOND * moveInfos[index].timetomove, this.moveToPoint, this).autoDestroy = true;

 

So is it possible to pause the game and still be able to have tweens, or another way to solve this problem would be to individually pause all user setted timed events? Is there an array of timeouts set by the user somewhere to be find?

 

 

In 1.1.4 the game no longer un-pauses on pointer events, however what you're needing is for the ability to pause a single State, where-as game.pause literally pauses the entire game and all sub-systems within. There's no way to do this 'natively' yet, but we have a States overhaul on the roadmap, so it's definitely coming soon. In the meantime you would need to work something out yourself from within your game code really, sorry.

 

 

Or is this possible yet?

Link to comment
Share on other sites

Solved the issue by creating my own timer and adding timed events to it like so:

// at createthis.customTimer = this.game.time.create(false);this.customTimer.resume();this.customTimer.running = true;...pauseOn : function(){   this.pauseMenu.show();   this.customTimer.pause();   this.physics.p2.pause = true;},...pauseOff : function(){   this.pauseMenu.hide();   this.customTimer.resume();   this.physics.p2.pause = false;}....//inside object which is using timerthis.game.customTimer.add(Phaser.Timer.SECOND * moveInfos[index].timetomove, this.moveToPoint, this);//

I hope people find it useful

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...