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?

You can switch scenes forever to your heart's content :)

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.

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()

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.

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.

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!

HURRAH!

views:1326 update:2011/10/12 18:33:00
corona forums © 2003-2011