so recentlty for my game I've been working on a button that takes the player back to the main menu, however for some reason it doesn't matter where you touch on the scene, it still goes o the menu. I just want it so that when i click the image that it goes to the menu.
heres the code:
function scene:createScene(event)
screenGroup = self.view
local createHud = function ()
gameBg = display.newImage("bg.png")
lvlnumber = display.newImage("lvlnumber.png", 0, -6)
menubutton = display.newImage("menubutton1.png", -10, -6)
screenGroup:insert(gameBg)
screenGroup:insert(lvlnumber)
screenGroup:insert(menubutton)
end
end
function scene:enterScene(event)
local group = self.view
local function onSceneTouch( event )
if event.phase == "ended" then
storyboard.gotoScene( "menu", "slideRight", 500 )
return true
end
end
function startButtonListeners(action)
if(action == 'add') then
menubutton:addEventListener('touch', onSceneTouch)
end
end
startButtonListeners('add')
gameListeners("add")
end
any help? Thanks!
createHudfunction is defined but never gets executed. - Egor Skriptunoff