gotoScene help needed?

Hey everyone,

I am having trouble with storyboard.gotoScene. When I click the button which is supposed to send the scene to “menu” nothing happens. Here is my code. Would appreciate if someone could find the bug. (By the way, If i change the storyboard.gotoScene(“menu”) part to something else it works, just not with the the gotoScene command)

[code]

function touched( event )
if(event.x < gameOver.x + 20 and event.x > gameOver.x - 100 and event.y < gameOver.y + 50 and event.y > gameOver.y - 50) then
storyboard.gotoScene( “menu” )

else
if(monster.isAlive == true) then
if(event.phase == “began”) then
if(event.x < 145) then
if(onGround) then
monster.accel = monster.accel + 29
audio.play(jump)

end
else
for a=1, blasts.numChildren, 1 do
if(blasts[a].isAlive == false) then
blasts[a].isAlive = true
blasts[a].x = monster.x + 10
blasts[a].y = monster.y
audio.play(shot)
break

else
if(event.x < play.x + 50 and event.x > play.x - 50 and event.y < play.y + 50 and event.y > play.y - 50) then

speed = 10

else

if(event.x < pause.x + 20 and event.x > pause.x - 20 and event.y < pause.y + 20 and event.y > pause.y - 20) then
speed = 0
monster.alive = false
monster:pause()

play.x = display.contentWidth*.7
play.y = display.contentHeight/10

end
end
end
end
end
end
end
end
end [import]uid: 175550 topic_id: 31246 reply_id: 331246[/import]

Do I need to have some code earlier in the program which allows the command to work? [import]uid: 175550 topic_id: 31246 reply_id: 124975[/import]

Yes sir you’re missing the storyboard template with the “createScene, enterScene,exitScene,and destroyScene” code. You have to insert your code into their code. [import]uid: 75779 topic_id: 31246 reply_id: 124979[/import]

I have that code though, I have it in my “menu” scene as well. Strange:/ [import]uid: 175550 topic_id: 31246 reply_id: 125002[/import]

We would need to see code for how your scene is constructed. For example, if you didn’t insert your display objects into the scene group (“group” in the scene template) then you wouldn’t notice a scene change at all.

You may want to add a scene change effect to your gotoScene command just so that it makes a scene switch easier to notice (for debug purposes)… [import]uid: 41884 topic_id: 31246 reply_id: 125004[/import]

I inserted everything on the screen into a group. Ok, I will try adding an effect, to make it easier to debug. [import]uid: 175550 topic_id: 31246 reply_id: 125007[/import]

I got closer in solving the problem. I put “storyboard.gotoScene(“menu”, fade, 500”) and the screen faded but didn’t go to the scene. [import]uid: 175550 topic_id: 31246 reply_id: 125008[/import]

Please help me, the screen is fading, but is not going to the different scene. [import]uid: 175550 topic_id: 31246 reply_id: 125009[/import]

Do I need to have some code earlier in the program which allows the command to work? [import]uid: 175550 topic_id: 31246 reply_id: 124975[/import]

Yes sir you’re missing the storyboard template with the “createScene, enterScene,exitScene,and destroyScene” code. You have to insert your code into their code. [import]uid: 75779 topic_id: 31246 reply_id: 124979[/import]

I have that code though, I have it in my “menu” scene as well. Strange:/ [import]uid: 175550 topic_id: 31246 reply_id: 125002[/import]

We would need to see code for how your scene is constructed. For example, if you didn’t insert your display objects into the scene group (“group” in the scene template) then you wouldn’t notice a scene change at all.

You may want to add a scene change effect to your gotoScene command just so that it makes a scene switch easier to notice (for debug purposes)… [import]uid: 41884 topic_id: 31246 reply_id: 125004[/import]

I inserted everything on the screen into a group. Ok, I will try adding an effect, to make it easier to debug. [import]uid: 175550 topic_id: 31246 reply_id: 125007[/import]

I got closer in solving the problem. I put “storyboard.gotoScene(“menu”, fade, 500”) and the screen faded but didn’t go to the scene. [import]uid: 175550 topic_id: 31246 reply_id: 125008[/import]

Please help me, the screen is fading, but is not going to the different scene. [import]uid: 175550 topic_id: 31246 reply_id: 125009[/import]