I've been playing with a game for my elementary students and am having director class issues. When I try to change the scene, things work fine until I have my variable set to true. If I set the variable set to true outside of a function or within the director function, things work fine. But I have an onComplete=changeToScene that call the variable true and nothing happens. I put a print for the terminal and the print shows just fine and I don't see any errors.
The following code works just fine:
1 2 3 4 5 6 7 8 9 | function changeScene() testing = true if testing == true then director:changeScene("sceneOne"); print("aAAAAARRRRR") end function cleanUp (event) end end |
sorry but can't tell you any thing as the problem is not in any code you had posted i had done quick test and that works
here is my test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | module(..., package.seeall) function new() local localGroup = display.newGroup() local corrTile = display.newRect(0,0,100,100) function changeToScene() testing = true changeScene() end transition.to(corrTile, {time = 1000, delay = 1500, alpha = 0, y=0, rotation=90, onComplete=changeToScene}) function changeScene() if testing == true then director:changeScene("modeSelect"); print("aAAAAARRRRR") end function cleanUp (event) end end return localGroup end |
Thanks for the reply hgvyas123. I thought I was going nuts. I don't know what I overlooked, but when I deleted that part and retyped it this morning it worked.
greata.....
Doesnt changeToScene() need to call changeScene() after setting testing to true?
I can't see where in the code that changeScene() would ever get called.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function changeToScene() testing = true changeScene() end transition.to(corrTile, {time = 1000, delay = 1500, alpha = 0, y=0, rotation=90, onComplete=changeToScene}) function changeScene() if testing == true then director:changeScene("sceneOne"); print("aAAAAARRRRR") end function cleanUp (event) end end --the AAAARRRR prints, but no scene change |