removeSelf() problem

local onImage11Collision = function ( self, event )  
  
  
 if( self.type == "bomba" and event.other.type == "cauldron" ) then  
 score.setScore (score.getScore()+25)  
 numCaveiras = numCaveiras + 1  
 end  
  
 local greenPoof  
 greenPoof = display.newImageRect( "imagens/bola.png", 30, 30 )  
 greenPoof.alpha = 1.0  
 greenPoof.isVisible = false  
  
 gameGroup:insert( greenPoof )  
  
  
 -- Poof code below --  
 if poofTween then transition.cancel( poofTween ); end  
  
 greenPoof.x = self.x; greenPoof.y = self.y  
 greenPoof.alpha = 0  
 greenPoof.isVisible = true  
  
 local fadePoof = function()  
 transition.to( greenPoof, { time=300, alpha=0 } )  
 local complete1 = function (e)  
 greenPoof:removeSelf()  
 end  
  
 tempoDestroi = timer.performWithDelay( 300, complete1, 1)  
 end  
 poofTween = transition.to( greenPoof, { time=100, alpha=1.0, onComplete=fadePoof } )  
  
  
 self.parent:remove( self )  
 self = nil   
 end  

this is my code for collision when a object collide with ground or my cauldron
but i’m getting a little problem… if a object collide with the ground or caldroun before previous, the local complete1 = function (e) greenPoof:removeSelf() end dont work and the greenpoof still there and dont remove after that =S

I have 12 collision code, all the same… if have a way to do this work… dont know how
thanks [import]uid: 23063 topic_id: 10683 reply_id: 310683[/import]

I suspect this is the usual ‘trying to remove a physics objects within a collision event’ issue, but what error message are you getting? [import]uid: 8271 topic_id: 10683 reply_id: 38768[/import]

i dony get a error, the error is that when 2 objects collide together, only the last to collide removeSelf
understand?

if a object are in process of removing, that is between 300 milliseconds, and another objects collide… the first objects will stop of removing self. its like the reference of object change for the new object that collide after, forgetting the first object [import]uid: 23063 topic_id: 10683 reply_id: 38797[/import]