I have a problem about changing scene.
After I add the touch function (gotoScene) to the start_btn, but no matter where i tapped in the simulator, it goes to the game scene.
(What i want is to change scene, only when i tap the start_btn)
Can anyone help me with this problem?
Here is my start.lua
[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local w = display.contentWidth
local h = display.contentHeight
local cx = display.contentCenterX
local cy = display.contentCenterY
function startGame (event)
if event.phase == “ended” then
storyboard.gotoScene (“game”)
end
end
function scene:createScene( event )
local screenGroup = self.view
start_btn = display.newImageRect (“PressStart.png”, 900, 700)
start_btn.x = cx - -18
start_btn.y = cy - -55
screenGroup:insert(start_btn)
end
function scene:enterScene( event )
start_btn:addEventListener (“touch”, startGame)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
return scene[/lua]
And here is my game.lua
[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
return scene[/lua]