I have an object that on collision I would destroy using object:removeSelf(),
instead of that I would like to have the object shrink down to nothing so it appears to be
losing energy. Would someone help me accomplish this. Thanks!
function ball1:collision (event)
if (event.other.name == ‘radar1’) then
ball1:removeSelf()
ball1=nil
end
end
Well, you can either animate this using a sprite, or you can just transition it:
[lua]transition.to( ball1, { time=1000, xScale=0, yScale=0 } )[/lua]
I also suggest you disable the physics body (or remove it, or turn it into a sensor) so it won’t collide with anything while it’s “dying”. This of course will need to be done using a 10 millisecond timer, since you can’t change a body’s active state in the collision game cycle.
Brent
Bladko
March 20, 2013, 10:37am
3
bjsorrentino:
Well, you can either animate this using a sprite, or you can just transition it:
[lua]transition.to( ball1, { time=1000, xScale=0, yScale=0 } )[/lua]
I also suggest you disable the physics body (or remove it, or turn it into a sensor) so it won’t collide with anything while it’s “dying”. This of course will need to be done using a 10 millisecond timer, since you can’t change a body’s active state in the collision game cycle.
Brent
you cannot scale object to size of 0 because it will crash app. It is safe to scale object to 0.001 thou.
Well, you can either animate this using a sprite, or you can just transition it:
[lua]transition.to( ball1, { time=1000, xScale=0, yScale=0 } )[/lua]
I also suggest you disable the physics body (or remove it, or turn it into a sensor) so it won’t collide with anything while it’s “dying”. This of course will need to be done using a 10 millisecond timer, since you can’t change a body’s active state in the collision game cycle.
Brent
Bladko
March 20, 2013, 10:37am
5
bjsorrentino:
Well, you can either animate this using a sprite, or you can just transition it:
[lua]transition.to( ball1, { time=1000, xScale=0, yScale=0 } )[/lua]
I also suggest you disable the physics body (or remove it, or turn it into a sensor) so it won’t collide with anything while it’s “dying”. This of course will need to be done using a 10 millisecond timer, since you can’t change a body’s active state in the collision game cycle.
Brent
you cannot scale object to size of 0 because it will crash app. It is safe to scale object to 0.001 thou.