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:
function changeScene()
testing = true
if testing == true then
director:changeScene("sceneOne");
print("aAAAAARRRRR")
end
function cleanUp (event)
end
end
but if testing is called to true inside of a different function, only print(“aAAAARRRRR”) works
function changeToScene()
testing = true
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
Does anyone have any ideas? I’m happy to share the whole file if that helps.
Thanks [import]uid: 48122 topic_id: 10529 reply_id: 310529[/import]
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
[lua]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[/lua]
[import]uid: 12482 topic_id: 10529 reply_id: 38374[/import]
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. [import]uid: 48122 topic_id: 10529 reply_id: 38409[/import]
greata… [import]uid: 12482 topic_id: 10529 reply_id: 38415[/import]
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.
[code]
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
[/code] [import]uid: 10389 topic_id: 10529 reply_id: 38891[/import]