Can I use director class to make a pause menu? What is the best way to make a pause menu that can be accessed throughout the game? Thanks in advance. [import]uid: 54001 topic_id: 12013 reply_id: 312013[/import]
Pause menus are (in my experience) usually pop ups with everything behind them temporarily suspended.
Director for a pause menu in its own scene might be a bit fiddly; you’d have to save the place of all your objects.
Peach [import]uid: 52491 topic_id: 12013 reply_id: 43871[/import]
You can use the new Popup function if you have Director 1.3. Otherwise you can create two groups within the group that you will return in your new() function(no matter how its arranged if everything is in the group that is returned, the scene will be cleaned properly). One group is for the game and the other group is for the menu.
You can wrap all your functions with a Boolean that changes if the game is paused or not and then pause physics. If you do that right the game should visually pause.
Then with the other group you can have all your menu items. Be sure to have this group declared after the other group.
[import]uid: 54716 topic_id: 12013 reply_id: 44109[/import]
I use director and physics engine. I use a very simple method that works well for me. I place a pause button at the top right of the game screen with an alpha set to about 0.4 so its not too distracting. Then have the pause menu text, buttons, images or whatever set to around y = -100 or less so it is off screen and not visible. When the user presses the pause button the physics engine pauses and each of the pause menu items transition down. If the user wants to go back to the game he can press the resume button and the menu items transition back to y = -100 and physics engine starts running again. My pause and resume listeners look like the following.
[blockcode]
function pauseButtonListener( event )
if event.phase == “ended” then
physics.pause()
if fxVolumeOn == true then audio.play(clickSound) end
transition.to( gamePausedTxt, { time=700, y = 200, transition=easing.outQuad} )
transition.to( resumeButton, { time=700, y = 300, transition=easing.outQuad} )
transition.to( backButton, { time=700, y = 400, transition=easing.outQuad} )
end
end
function resumeButtonListener( event )
if event.phase == “ended” then
if fxVolumeOn == true then audio.play(clickSound) end
transition.to( gamePausedTxt, { time=400, y = -100})
transition.to( resumeButton, { time=400, y = -100} )
transition.to( backButton, { time=400, y = -100} )
physics.start()
end
end
[/blockcode]
I hope this helps or gives you an idea about how to create your own pause menu.
Glenn
[import]uid: 38820 topic_id: 12013 reply_id: 44133[/import]