Jump to content

How to pause two sprite boxes?


spinnerbox
 Share

Recommended Posts

I found there are two different approaches on how to pause game.

game.pause = true; efectively pauses all subsystems in the game including the buttons, so I cannot press on them if this property is set to true.

Yes I found this example http://phaser.io/examples/v2/misc/pause-menu which calculates where you pressed and if the click was on the pause btn it unpauses the game.

I have just two sprites with two text objects above them. They move as text boxes togheter and fall down to the ground. Once they reach(hit) the ground the game is over.

I also found this property Physics.Arcade.isPaused which I cannot find in Phaser 2.2.2 documentation and my browser as well tells me that this property does not exits.

What is the best way to stop two text boxes to fall down when I press a pause button but being able to press that button again?

Should I use some hacks like remove update function and then add it again or something like set sprite velocity to 0 and then revert it back again to 100.?

Link to comment
Share on other sites

pauseUnpauseGame: function () {
   if (leftLetterBox.paused) {
        leftLetterBox.unpause();
	rightLetterBox.unpause();
   } else {
        leftLetterBox.pause();
        rightLetterBox.pause();
   }
}
letterBox.paused = false;
letterBox.pause = function () {
     letterBox.graphics.body.velocity.y = 0;
     letterBox.paused = true;
};
            
letterBox.unpause = function () {
     letterBox.graphics.body.velocity.y = si.Const.SPEED_EASY;
     letterBox.paused = false;
};

Where leftLetterBox and rightLetterBox are of type letterBox. This did the job :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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