Can't get Director to load new scenes

I have no idea what’s wrong. I was working with Director 1.2, and had the following issue. Director 1.3 came out and had the same problem, so it’s not specific to the version. Also, using .484 version of Corona.

OK, the main loads fine, changeScene to a splash screen fine, that changes to a menu fine. Here’s where I run into issues. When I did a changescene to a menu choice scene, it would load it for a split second, then switch back to the menu scene and load that again. There was no code on that menu to do that. Also no errors.

So I created a test project. Made a main, screen1, screen2, and screen3. All using the templates from 1.3. Main loads screen1, that’s OK. In screen1 I had a print command and a scene change to screen2, thats both worked. In screen2, I did the same, print and change, but this time nothing. No errors, nothing.

I’m confused. Can you not keep switching scene after scene, or is there a limit?
[import]uid: 21992 topic_id: 11987 reply_id: 311987[/import]

You can switch scenes forever to your heart’s content :slight_smile:

Perhaps post some of your code for us to look at?

All I can guess is you are using scenes with builtin timed scene-switching (which a lot of people do) and if you are basing your new scenes on this splash one, it will keep changing scenes after 1-5 seconds. [import]uid: 10389 topic_id: 11987 reply_id: 43710[/import]

OK, here is my test project. The only commands outside the template I use are print() and changeScene(). In the terminal, it will print main and screen1, and thats it. Never goes on to the other two screens. What crazy thing am I doing wrong?

Thanks…

MAIN.LUA
[lua]local director = require(“director”)

local mainGroup = display.newGroup()

local main = function ()

mainGroup:insert(director.directorView)

print(“main”)
director:changeScene(“screen1”,“fade”)

return true
end

main()[/lua]

SCREEN1.LUA
[lua]module(…, package.seeall)

new = function ()

local localGroup = display.newGroup()

print(“screen1”)
director:changeScene( “screen2”, “fade” )

return localGroup

end[/lua]

SCREEN2.LUA
[lua]module(…, package.seeall)

new = function ()

local localGroup = display.newGroup()

print(“screen2”)
director:changeScene( “screen3”, “fade” )

return localGroup

end[/lua]

SCREEN3.LUA
[lua]module(…, package.seeall)

new = function ()

local localGroup = display.newGroup()

print(“screen3”)

return localGroup

end[/lua]
[import]uid: 21992 topic_id: 11987 reply_id: 43782[/import]

Looks fine to me.
Try putting in a delay before switching, perhaps?
Just as a test.
I will have to wait until I’m home again to test it out as I’m at work the next 8 hrs. [import]uid: 10389 topic_id: 11987 reply_id: 43817[/import]

If its jumping back to an older screen, then the error is in one of your earlier scenes. I had this problem before and it’s usually from something dumb especially if there isn’t an error. When it happened to me, I found that I had required a file twice when for debugging issue and never deleted it.
Strip down your files until the issue is fixed and then lay piece back in a little at a time. [import]uid: 54716 topic_id: 11987 reply_id: 44042[/import]

Yes, I found it. It was a problem with an earlier screen.

Timers/Events were causing the issues. I eliminated them or removed/canceled them before changing scenes and my problems are solved. I also had the same function twice, copy paste instead of moving it.

Thanks everyone for the help. Never thought to go backwards to previous scenes to look for the issues. Learn something new every day.

Thanks all!
[import]uid: 21992 topic_id: 11987 reply_id: 44119[/import]

HURRAH! [import]uid: 10389 topic_id: 11987 reply_id: 44122[/import]