For making a “main menu” button, there’s many different ways (some better than others). I personally have a “main menu” button already created, and either have it “slide” into view when the pause is pressed, then “slide” back out. I used tranisitions for this way.
Another way is to “hide” the button, but when you press pause it will appear.
For example, have your button set to [lua]pauseBtn.alpha = 0[/lua], then when paused, set alpha = 1. When unpaused, set back to alpha = 0 to hide it.
Sample:
[lua]–Pause button
local pauseBtn = display.newRect( 40, 40, 60, 30 )
localGroup:insert(pauseBtn)
pauseBtn.alpha = 0
–Pause function
local function pause ()
if paused == false then
physics.pause()
timer.cancel(orbTimer)
timer.cancel(bombTimer)
pauseBtn.alpha = 1
paused = true
elseif paused == true then
physics.start()
orbTimer = timer.performWithDelay( 1500, spawnOrb, 0 )
bombTimer = timer.performWithDelay( 2700, spawnBomb, 0 )
pauseBtn.alpha = 0
paused = false
end
end
pauseBtn:addEventListener(“tap”, pause)[/lua]
Keep in mind this is sample code, if you put this in your game, it’s going to hide your pause button! [import]uid: 129334 topic_id: 24481 reply_id: 99139[/import]