Timer Function Won't go away

My image appears, and i put the following code in,

(that is only a little section of the code) I want to know, how to make it so that, after two seconds, the image disappears, and then the Director Class transitions to level1. Please tell me how. Thanks.

[code]
local mainGroup = display.newGroup()
local image = display.newImage(“loading.png”)
image.x = display.contentWidth/2
image.y = display.contentHeight/2

local function main()
mainGroup:insert(director.directorView)
local tmr = timer.performWithDelay(2000, main, 1)
director:changeScene( “level1” )

return true
end
[/code] [import]uid: 19768 topic_id: 6642 reply_id: 306642[/import]

try this maybe

[lua]local mainGroup = display.newGroup()
local image = display.newImage(“loading.png”)
image.x = display.contentWidth/2
image.y = display.contentHeight/2

local function goLevel1()

director:changeScene( “level1” )

end

local function main()
mainGroup:insert(director.directorView)
local tmr = timer.performWithDelay(2000, goLevel1, 1)
end

main()[/lua] [import]uid: 6645 topic_id: 6642 reply_id: 23161[/import]

Yea, that didn’t do anything. NOw it’s just stuck at that image. [import]uid: 19768 topic_id: 6642 reply_id: 23198[/import]

@Evil

I think this is the line you are missing.

[code]localGroup:insert(loadingImage)

function new()
local localGroup = display.newGroup()

local theTimer
local loadingImage

local showLoadingScreen = function()
loadingImage = display.newImageRect( “yourImage.png”, 1024, 768 )
loadingImage.x = 512; loadingImage.y = 384
localGroup:insert(loadingImage)

local goToLevel = function()
director:changeScene( “level1” )
end

theTimer = timer.performWithDelay( 500, goToLevel, 1 )
end

showLoadingScreen()

unloadMe = function()
end

– MUST return a display.newGroup()
return localGroup
end

[import]uid: 16527 topic_id: 6642 reply_id: 23518[/import]

Yea I fixed it. I just added a new timer. I put a timer to wait ty’ll 1500 miliseconds before transitioning. And then I did a removeImage function, and set it to the same timer. [import]uid: 19768 topic_id: 6642 reply_id: 23533[/import]

Hey Evil,

Speaking of timers. Do you know what Ricardo is referring to when he states we must clean our own Timers? I am a bit lost about this because that is the biggest part of the code that has changed over the course of the revisions to the Director Class.

I have just created the following code with the timer at the end. Is this the kind of timer he is talking about and if so how are we supposed to clean it?

Thanks
Rob

[code]local touchObject1 = function (event)
if event.phase == “ended” then
local chalkbdImage = display.newImageRect( “zImages/chalkbd.png”, 825, 568 )
chalkbdImage.x = 512; chalkbdImage.y = 384
localGroup:insert(chalkbdImage)
audio.play( slideSound )

local removechalkbd = function()
chalkbdImage:removeSelf()
end

timer.performWithDelay(5000, removechalkbd)

end
end

textObject1:addEventListener(“touch”, touchObject1)

[import]uid: 16527 topic_id: 6642 reply_id: 23536[/import]

I would not be the person you should ask. Haha i read your comment, looked at the code and was like, “umm…yea… don’t know” haha

But I do need your help that you possibly might know, go to my other thread, Collision Function Help!

Where others are submitting their ideas for the same thing! So if you know how to fix that problem in there, you fix your problem! [import]uid: 19768 topic_id: 6642 reply_id: 23541[/import]