Pause game play

We’re generating a standard in-game pop-up menu. It’s a box containing ‘resume game’ and ‘end game’ buttons that appears when the game is paused. There is a translucent overlay, but the underlying elements in the game are still interactive. Conducting a series of removeEventListeners would be really complex.

How can you pause the game play or at least stop a bunch of objects with listeners on them from paying attention to touches? Also tried ‘isTestHitable = false’, but this only applies to objects that aren’t visible.

Many thanks in advance, [import]uid: 21125 topic_id: 6950 reply_id: 306950[/import]

Take a screenshot of the game at the point they want to pause and then display that picture “on top” of everything else? It’ll look like the game but you won’t have any listeners attached to it.

(I put a question mark in there because I have no idea if that would work, but it sounds good to me at this point!) :wink:

Jay
[import]uid: 9440 topic_id: 6950 reply_id: 24347[/import]

@Fixdit

I had exactly the same issue and this is what I did.

I have a function that displays my translucent overlay. I add an event listener to the translucent overlay that effectively captures all touch events and prevents then passing on to the elements under the overlay.

  
function clickFadeBg( event )  
  
 return true  
  
end  
  
function displayFadeBg()  
  
 fadeBg.alpha = 0  
 fadeBg.x = 160  
 fadeBg.y = 240  
  
 transition.to( fadeBg, { time=250, alpha=1} )  
  
 fadeBg:addEventListener("touch", clickFadeBg)  
  
end  
  

This worked well for dealing with the touch event listeners. Unfortunately as this menu can be displayed at any point within my game I also ended up having to pause all my transitions and other moving elements. For example at the end of a round, I have a message animate onto the screen. If someone clicks the menu button at this point, I need to pause this animation while the menu is displayed and resume the animation when the menu is closed.

It was not a fun job but it was necessary and will certainly make me think about the pause functionality from the outset for my next game [import]uid: 7863 topic_id: 6950 reply_id: 24381[/import]