hey folks,
I’m a beginner and now having some issues.
Basicly I have a hero (in the middle of the screen) and falling objects from sky.
I want those objects to appear with a Delay of 2 seconds (that works like a charm in my code), but I also want to disapear them, when they go offscreen OR automaticly after 8 seconds. how can I implement that function in my code?
--RAIN
drops = 0 --Counter
RemoveDrop = function()
i:removeSelf()
i = nil
drops = drops-1 --Counter
MakeItRain() --Loop
end
AddDrop = function()
drops = drops+1 --Counter
local autoSize = math.random( 60, 120 )
i = display.newImageRect( "images/windows.png", autoSize, autoSize )
i.x = math.random( 0, device\_w )
physics.addBody( i, { density = 1.8, friction = 0.5, bounce = 0.2 } )
i.bodyType = "dynamic"
MakeItRain() --Loop
end
MakeItRain = function()
if( drops \< 4 ) then --Counter
timer.performWithDelay( 2000, AddDrop )
end
--timer.performWithDelay( 8000, RemoveDrop )
end
MakeItRain()
First I thought that I would be able to do this If every Image would have a different name. So I can talk to each Image independently… What do you think? I’m just going crazy… stuggling about 2 days now
[import]uid: 73502 topic_id: 12565 reply_id: 312565[/import]