hey all - just a tiny question:
i have this function which makes one new displayobject, imagine a fireball.
i have a timer.performwithdelay to execute that function 10 times which spawns at different random lokation on the screen
my problem is now that - when i try make a function “despawnFireball” like so (see below). it will only remove the newest fireball that spawned. (i suspect there is a really easy solution, i just cant see it, im “new” to Corona so forgive me if its wrong forum or something silly easy, :P)
how do i remove the fireballs which is clicked on and not just the newest one created?
(i tried to do it with tables / arrays without luck but there must be a easier way?) :o
[code]
function spawnFireBall( event )
print(“fireball spawned!”)
newFireBall = display.newCircle( 0, 0, 20 )
newFireBall.x = display.contentWidth * 0.5
newFireBall.y = display.contentHeight * 0.5 - 20
newFireBall:setFillColor(255,0,0)
groupOfFireBall:insert( newFireBall )
randX = math.random (100, display.contentWidth - 100)
randY = math.random (20, display.contentHeight - 20)
– random positions to move to for fireballs
transition.to(newFireBall, {time = 500, x = randX, y = randY})
newFireBall:addEventListener( “touch”, smashFireBall )
end
tmr = timer.performWithDelay(1000,spawnFireBall,5);
function smashFireBall( event )
print(“fireball destroyed!”)
newFireBall:removeSelf();
end
[/code] [import]uid: 163092 topic_id: 30564 reply_id: 330564[/import]
i knew it had to be really that simple, easy soiution. i just sat there and starring blind for hours…