Transition and Remove object experiment

I was having trouble with the screen update in a sequence where I wanted to transition a screen display object, then remove it when the transition was done. I came up with this way to do that, taking advantage of the “onComplete” parameter to call a function to do all my dirty work.

-- Transition and Remove object experiment  
-- Perform a transition on a screen display object, then remove it  
-- in iPhone format, the order of the statements is crucial  
  
local playerObj = display.newCircle( 40, 60, 40 )  
playerObj:setFillColor( 245,245,0 )  
  
local function callRemoveObj()  
 print("doing callRemoveObj")  
 playerObj:removeEventListener( "tap", doTransition )  
 playerObj:removeSelf()  
end  
  
----------------------------------------------------------  
-- when the object is tapped on,  
-- send this player to the bench and remove the object.  
----------------------------------------------------------  
function doTransition( event )  
 transition.to( event.target, { time=1000, x=280, y=440, onComplete=callRemoveObj } )  
end  
playerObj:addEventListener( "tap", doTransition )  
  

[import]uid: 6114 topic_id: 2312 reply_id: 302312[/import]