Moving to a new storyboard scene

Im trying to move to a new storyboard scene when a image is pushed but its not working.  Can someone take a look and tell me what I’m missing?[lua]local storyboard = require(“storyboard”)

local scene = storyboard.newScene()

function startGame(event)
if event.phase == “ended” then
storyboard.gotoScene(“game”)
end
end

function scene:createScene(event)

local sceneGroup = self.view

background = display.newImageRect(“water.png”,640,1136)
background.anchorX = .5
background.anchoryY = .5
background.x = display.contentCenterX
background.y = display.contentHeight / 2
sceneGroup:insert(background)

frog = display.newImageRect(“frog.png”,160,160)
frog.anchorX = .5
frog.anchorY = .5
frog.x = display.contentCenterX
frog.y = display.contentCenterY + 400
sceneGroup:insert(frog)

title = display.newImageRect(“title.png”,640,256)
title.anchorX = .5
title.anchorY = .5
title.x = display.contentCenterX
title.y = display.contentCenterY - 300
sceneGroup:insert(title)

start = display.newImageRect(“start.png”,160,60)
start.anchorX = .5
start.anchorY = .5
start.x = display.contentCenterX
start.y = display.contentCenterY + 200
sceneGroup:insert(start)
end

function scene:enterScene(event)
mainMenu.addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
mainMenu.removeEventListener(“touch”,startGame)
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene[/lua]

You’ve added the touch listener to an object called mainMenu, but I don’t see that you’ve created this object anywhere.  

Also you should be using : instead of . when calling addEventListener

mainMenu:addEventListener("touch", startGame)

fixed the . instead of : typo and mainMenu should have been scene. here is the updated code but it still doesn’t work…[lua]local storyboard = require(“storyboard”)

local scene = storyboard.newScene()

function startGame(event)
if event.phase == “ended” then
storyboard.gotoScene(“game”)
end
end

function scene:createScene(event)

local sceneGroup = self.view

background = display.newImageRect(“water.png”,640,1136)
background.anchorX = .5
background.anchoryY = .5
background.x = display.contentCenterX
background.y = display.contentHeight / 2
sceneGroup:insert(background)

frog = display.newImageRect(“frog.png”,160,160)
frog.anchorX = .5
frog.anchorY = .5
frog.x = display.contentCenterX
frog.y = display.contentCenterY + 400
sceneGroup:insert(frog)

title = display.newImageRect(“title.png”,640,256)
title.anchorX = .5
title.anchorY = .5
title.x = display.contentCenterX
title.y = display.contentCenterY - 300
sceneGroup:insert(title)

start = display.newImageRect(“start.png”,160,60)
start.anchorX = .5
start.anchorY = .5
start.x = display.contentCenterX
start.y = display.contentCenterY + 200
sceneGroup:insert(start)
end

function scene:enterScene(event)
scene:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
scene:removeEventListener(“touch”,startGame)
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene[/lua]

I figured it out:

scene needed to be changed to start:

[lua]function scene:enterScene(event)
scene:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
scene:removeEventListener(“touch”,startGame)
end[/lua]

changed to:

[lua]function scene:enterScene(event)
start:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
start:removeEventListener(“touch”,startGame)
end[/lua]

You’ve added the touch listener to an object called mainMenu, but I don’t see that you’ve created this object anywhere.  

Also you should be using : instead of . when calling addEventListener

mainMenu:addEventListener("touch", startGame)

fixed the . instead of : typo and mainMenu should have been scene. here is the updated code but it still doesn’t work…[lua]local storyboard = require(“storyboard”)

local scene = storyboard.newScene()

function startGame(event)
if event.phase == “ended” then
storyboard.gotoScene(“game”)
end
end

function scene:createScene(event)

local sceneGroup = self.view

background = display.newImageRect(“water.png”,640,1136)
background.anchorX = .5
background.anchoryY = .5
background.x = display.contentCenterX
background.y = display.contentHeight / 2
sceneGroup:insert(background)

frog = display.newImageRect(“frog.png”,160,160)
frog.anchorX = .5
frog.anchorY = .5
frog.x = display.contentCenterX
frog.y = display.contentCenterY + 400
sceneGroup:insert(frog)

title = display.newImageRect(“title.png”,640,256)
title.anchorX = .5
title.anchorY = .5
title.x = display.contentCenterX
title.y = display.contentCenterY - 300
sceneGroup:insert(title)

start = display.newImageRect(“start.png”,160,60)
start.anchorX = .5
start.anchorY = .5
start.x = display.contentCenterX
start.y = display.contentCenterY + 200
sceneGroup:insert(start)
end

function scene:enterScene(event)
scene:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
scene:removeEventListener(“touch”,startGame)
end

function scene:destroyScene(event)
end

scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)

return scene[/lua]

I figured it out:

scene needed to be changed to start:

[lua]function scene:enterScene(event)
scene:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
scene:removeEventListener(“touch”,startGame)
end[/lua]

changed to:

[lua]function scene:enterScene(event)
start:addEventListener(“touch”, startGame)
end

function scene:exitScene(event)
start:removeEventListener(“touch”,startGame)
end[/lua]