Repeated transitions on an image

I’m a noob, let’s get that out in the open now. So what I’m trying to do is get an image that has an eventListener attached, hit the event repeatedly. I want an image to go away when touched and then return after a period of time. This part works, what doesn’t work is repeating the process. I’ll post my code of what I have been playing with.

[lua]function boom( event )
local phase = event.phase
local t = event.target
local stage = display.getCurrentStage()

if (phase == “ended”) then
print(“we are here”)
local myIndex = t.myIndex
stage:setFocus( t, event.id )
print("myIndex " … myIndex )
transition.to( object[myIndex], { time=200, alpha=0} )
media.playEventSound( “beep.caf” )
transition.to( object[myIndex], { time=200, alpha=1.0, delay=2500 } )
end
end

The only code after this function is the screen setup. [import]uid: 10638 topic_id: 3291 reply_id: 303291[/import]

Can you explain what’s not working with your code? I tried it and it seems to do what I would expect. Here’s a slightly modified version of your code that I was using:

local rect = display.newRect(0, 0, 100, 100)  
rect:setFillColor(255,0,0)  
function boom( event )  
 local phase = event.phase  
 local t = event.target  
 local stage = display.getCurrentStage()  
  
 if (phase == "ended") then  
 print("we are here")  
 stage:setFocus( t, event.id )  
 transition.to( t, { time=200, alpha=0} )   
 transition.to( t, { time=200, alpha=1.0, delay=2500 } )  
 end  
end  
rect:addEventListener("touch", boom)  
  

Tim [import]uid: 8196 topic_id: 3291 reply_id: 10516[/import]

The problem comes in when I use an array to set up the images. On the first time it fires, everything works fine. However when I attempt to hit an image for the second time nothing happens. Essentially I set up some images, it varies on the number which is why I used an array, then I set a listener on each image. What I would like to do is have some images that will disappear when touched and then “respawn” and be available to repeat. [import]uid: 10638 topic_id: 3291 reply_id: 10560[/import]