Jump to content

Pause Menu


jdiego82
 Share

Recommended Posts

Hey, guys.

I'm trying to make a pause menu in my game while using the game.paused member, but it seems that Phaser has a weird way of pausing the game. It seems that everything is paused until a pointer input is entered, and then everything continues after that.

 

I want to make a pause menu where my sprites are paused (I'm using body.velocity for movement, so I can't figure out a way to do it with states), but pointer input is active.

 

I was thinking of using jQuery, but I'm targeting desktop and mobile devices, so I'm not sure if that's the best approach to this.

 

Does anybody know of a workaround, possibly without using jQuery?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I had to create one for myself .And it worked out good.
IT depends of what game you are making.

But i just  basscily

1. boolean for IsGamePaused.To return from update loop if paused.(changing on pause button click).

2.Have function which reads current physic bodies velocities.Saves them as new variables on object values.And set current ones as 0.
I had group of falling object.
So my code looked like that:
 

 for(var k=0;k<this.fallingGroup.length;k++){          this.fallingGroup.getAt(k).velocSavedY= this.fallingGroup.getAt(k).body.velocity.y ;      this.fallingGroup.getAt(k).velocSavedX=this.fallingGroup.getAt(k).body.velocity.x;       this.fallingGroup.getAt(k).body.velocity.y=0;       this.fallingGroup.getAt(k).body.velocity.x=0;                }

3.On unpause i did somthing like this :
 

  for(var k=0;k<this.ballGroup.length;k++){                     this.ballGroup.getAt(k).body.velocity.y=  this.ballGroup.getAt(k).velocSavedY;      this.ballGroup.getAt(k).body.velocity.x=   this.ballGroup.getAt(k).velocSavedX;          }

4.I didn't noticed any performance drops on this approach.But it might be not  a best way to do it .

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

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