Spawn image after its been removed question? HELP PLEASE

hey i was wondering, how can i make an image spawn again once its been removed? in my game, i have these bugs running around and once the player touches the bug, it is removed, it wont show up again, is there any way i can make the bug come back after its been removed and start the whole transition all over and over and over and over?

Could you set its alpha to 0 to make it invisible instead of removing it? You could then set the alpha back to 1 to make it reappear.

so what you're saying is, when the player touches the bugs in my game, set the alpha to 0 then back to 1 right?

so heres one code for my bug image

local bug = display.newImage( "roach.png" )
localGroup:insert(bug)
bug.x = -200
bug.y = 300
local function moveit (event)
transition.to(bug, {time=7000, x=-100, y=160})
local function moveback (event)
transition.to(bug, {time=2000, x=600, y=160})
end
timer.performWithDelay (2000, moveback, 1)
end

timer.performWithDelay(5000, moveit, 0)
local function killbug (event)
local blood = display.newImage ("blood.png")
transition.to( blood, { time=500, delay=3000, alpha=0 } )
blood.x = bug.x
blood.y = bug.y
score.setScore( score.getScore() + 10)
bug:removeSelf()
end

bug:addEventListener("touch", killbug)

how can i make it set the alpha to 0 instead of removing it when the player touches it, then back to 1??

views:1302 update:2011/10/4 8:06:35
corona forums © 2003-2011