Problem deleting a transition.to

Hi, I’m making a game which requires to delete some transition.to objects, everything is ok, but, if the transition.to obj reach the x and y point that is referred, I’m gonna lose a life, the problem is, when it is coming and I delete, all the others objects freeze and new ones keep coming.

Is there any easier or better way of making a object move somewhere then transition.to? [import]uid: 69287 topic_id: 12160 reply_id: 312160[/import]

If you’re using physics you could applyLinearImpulse.

If not, are you getting any errors? [import]uid: 52491 topic_id: 12160 reply_id: 44403[/import]

In my space shooter OmniBlaster, I use transition.to all the time for all my weapon fire (since its all going in a straight line).

[lua]local function removeCenterPhasers(t)
if phaserCenter ~= nil then
if phaserCenterTween ~= nil then
transition.cancel(phaserCenterTween)
phaserCenterTween = nil
end
phaserCenter:removeSelf()
phaserCenter = nil
end
end

phaserCenter = display.newImageRect(blastImg, 9, 32)
phaserCenter.x = myRocket.x + 32
phaserCenter.y = myRocket.y + 0
phaserCenterTween = transition.to(phaserCenter, { y = -32, time=500, onComplete=removeCenterPhasers})[/lua]
So when I create the transition.to, I store a reference to the transition into “phaserCenterTween” and when it ends up off screen (y = -32) I then remove that object and its tween from memory.

Now during my game play loop (eventListener on EnterFrame) I have code that detects if my blaster image object has collided with my table of targets:

[lua] if phaserCenter then
if hasCollided(bullets[i], phaserCenter) then
removeCenterPhasers(bullets[i])
end
end[/lua]

of course I’ve removed some other game play code to get this down to what you need. But the idea is to let the transition.to move your image. When it completes, use the call back function to clear the tween and clear the image. Then if it runs into something, get rid of it too. [import]uid: 19626 topic_id: 12160 reply_id: 44429[/import]

Thanks everyone for the support.

Robmiracle, I appreciate your help, even though it didn’t work out as planned here, some objects stills freezes, as I’m short on time, I’ll test peach pellen’s later. Thank you so much! [import]uid: 69287 topic_id: 12160 reply_id: 44451[/import]

Make the transition part of the object by changing phaserCenterTween to phaserCenter.tween.

You can delete lines 3 and 5 if you create a useless transition when creating the object, i.e. phaserCenter.tween = transition ( phaserCenter, { time = 1 } ) [import]uid: 6084 topic_id: 12160 reply_id: 44456[/import]