understanding onTransitionEnd(...) + box2D

Hi,

I’m slowly getting the hang of Lua and its idiosyncrasies, but there is this piece of code I wan’t some more clarification:

[lua]local function onCollision(self, event )

if ( event.phase == “began” ) then

if event.other.properties then

local item = event.other

local onTransitionEnd = function(event)
event:removeSelf()
insertClone()
end[/lua]

ok, this onCollision() method will be called whenever a collision event happens. Then if event.phase is “began”, a onTransitionEnd closure will be create and… this closure will be called exactly when?

[lua]-- Fade out the item
transition.to(item, {time = 200, alpha = 0, onComplete=onTransitionEnd})[/lua]

for what I know about box2d, bodies cannot be removed from the application in between collision phases (i.e. “began” and “ended”), so I guess that the transition will be completed after the box2d collision event is complete. But how exactly? This time item in transition to is updated after the collision is complete?

[import]uid: 31814 topic_id: 6944 reply_id: 306944[/import]