Hello, I am rather new to Corona SDK, but I am trying to write the code for a pause menu… Unfortunately the script I have to resume the game doesn’t work. I have it setup so that the button “resumeMenu” runs the script “resume”… That is supposed to get rid of “pauseMenu”, and “exitMenu”… This is the code I have, and any suggestions/help would be highly appreciated.
[code]
function new()
local localGroup = display.newGroup()
local isPaused = false
– Game
local score = 0
local background = display.newImage(“images/bk-default.png”)
background.x = display.contentCenterX
background.y = display.contentCenterY
localGroup:insert(background)
local scoreText = display.newText( "Score: "… score, 0, 0, native.systemFontBold, 16 )
scoreText:setTextColor(0, 0, 0)
scoreText.x = display.contentWidth / 4
scoreText.y = display.contentHeight / 8
localGroup:insert(scoreText)
local pause = display.newImage(“images/pause.png”)
pause.x = display.contentWidth / 4
pause.y = display.contentHeight / 18
pause.alpha = .5
localGroup:insert(pause)
– Touch to go back
local touched = function( event )
print(“Screen Change”)
director:changeScene(“menu”,“fade”)
end
local paused = function( event )
local resume
if isPaused == false then
isPaused = true
local pauseMenu = display.newImage(“images/Panel.png”)
pauseMenu.x = display.contentWidth / 2
pauseMenu.y = display.contentHeight / 2
pauseMenu.alpha = .5
localGroup:insert(pauseMenu)
exitMenu= ui.newButton{
defaultSrc = “images/Button.png”,
defaultX = 160,
defaultY = 32,
overSrc = “images/Button Over.png”,
overX = 160,
overY = 32,
id = “resumeMenu”,
text = “Exit”,
font = “Helvetica”,
textColor = { 0, 0, 0, 255 },
emboss = false
}
exitMenu:addEventListener( “tap”, touched )
exitMenu.x = display.contentWidth / 2
exitMenu.y = display.contentHeight / 3
resumeMenu= ui.newButton{
defaultSrc = “images/Button.png”,
defaultX = 160,
defaultY = 32,
overSrc = “images/Button Over.png”,
overX = 160,
overY = 32,
id = “resumeMenu”,
text = “Resume”,
font = “Helvetica”,
textColor = { 0, 0, 0, 255 },
emboss = false
}
resumeMenu:addEventListener( “tap”, resume )
resumeMenu.x = display.contentWidth / 2
resumeMenu.y = display.contentHeight / 4
end
end
pause:addEventListener(“tap”, paused)
local resume = function( event )
pauseMenu:removeSelf()
exitMenu:removeSelf()
end
unloadMe = function()
end
– MUST return a display.newGroup()
return localGroup
end
[/code] [import]uid: 26946 topic_id: 13321 reply_id: 313321[/import]
[import]uid: 3826 topic_id: 13321 reply_id: 48944[/import]