[SOLVED] Changing Scene's Automatically.

* To solve it i added a timer to the changeScene call.
Feel free to comment if you have anything to tell me. Thanks! =)

Hi there,
I’m using the director class, i know how to change scenes.

But on some scene’s i want to re-direct them to another scene.
I have code in, but it just passes over it and doesnt actually changescene.
I suspect it might be because director hasn’t finished the previous scene change.

Shortened and just shows the necessary structure.

module(..., package.seeall);  
  
function new()  
local Bat =0;  
  
local bg = display.newImage("Images/Forest.png", \_W, \_H);  
bg:setReferencePoint(display.CenterReferencePoint);  
bg.x = \_W/2; bg.y = \_H/2;  
localGroup:insert(bg);  
  
if(Bat == 0)then  
 director:changeScene("RandomBattle", "fade", "white") -- \<\<\<\<  
 print("It Does access this 'If' Statement.");  
end  
  
function changeScene(e)  
 if(e.phase == "ended") then  
 director:changeScene("Prologue", "fade");  
 package.loaded["Forest"] = nil  
 \_G["Forest"] = nil  
 end  
end  
  
bg:addEventListener("touch", changeScene);  
  
 return localGroup;  
end  

How would i make it so when this screen is accessed, it changes scene to another. (I will make it a randomise percentage later on.)

Thanks alot! [import]uid: 91798 topic_id: 22171 reply_id: 322171[/import]