Change physics size circle

Hi
I’m not too good at programming, so any help would be welcome

In my app i have a ball that increases in scale by 0.1 when it makes a collision with an enemy.
I know how to change the image size, but don’t know how to change the physics size of it.

One of the problems is that i have tryed to remove the physics from it to create again, but the function did nothing (is it because the object was moving?). I want the object to have the same velocity and direction on movment when i create the physics again (if removal is necessary).

Any one has a good way to do this physics size scalling thing (on one object only)?

Remember it is a ball, not a shaped object so scalefactor from physics editor does not work for me.

Thanks in advance
Best Regards

you could try removing the body and adding it with the new radius

Hi @thithous,

You can’t remove and then add a new physics body during the same application time-step as a collision. So, you’d need to perform that with a tiny delay (even 10 milliseconds), but the problem with that approach is that you’ll lose the velocity when you destroy the body. Even if you store the current velocity to a variable and reset it on the new body, you might notice a tiny “interruption” while the first body is destroyed and the new one is created.

For a better and smoother process, I suggest that you initially create a multi-element body using a series of concentric circles (of different sizes). Then, use pre-collision and PhysicsContact to determine which of these body parts is “active” for the object depending on its visual size.

Take care,

Brent

ty man. i ill try the first aproach and see how it looks like…
If it really have a noticeable interruption, then ill try to learn how to use this pre-collision event and physics contact method.
How can i create a multi-element body? I don´t know how physics works so well.

anyway thanks again
You have been very helpfull.

edit: the first aproach worked for me, but how can i get the radius propertie value from the old physics body? can those properties be accessed (like friction, density, radius and bounce)?

Hi @thithous,

If you haven’t located it already, I suggest you start at Corona University for learning about physics (and other things as needed):

http://coronalabs.com/resources/tutorials/physics-box2d/

Properties like radius and friction are not directly read-able from a body… you’d need to just set them as properties of the object when you create it, then access those properties later.

Take care,

Brent

you could try removing the body and adding it with the new radius

Hi @thithous,

You can’t remove and then add a new physics body during the same application time-step as a collision. So, you’d need to perform that with a tiny delay (even 10 milliseconds), but the problem with that approach is that you’ll lose the velocity when you destroy the body. Even if you store the current velocity to a variable and reset it on the new body, you might notice a tiny “interruption” while the first body is destroyed and the new one is created.

For a better and smoother process, I suggest that you initially create a multi-element body using a series of concentric circles (of different sizes). Then, use pre-collision and PhysicsContact to determine which of these body parts is “active” for the object depending on its visual size.

Take care,

Brent

ty man. i ill try the first aproach and see how it looks like…
If it really have a noticeable interruption, then ill try to learn how to use this pre-collision event and physics contact method.
How can i create a multi-element body? I don´t know how physics works so well.

anyway thanks again
You have been very helpfull.

edit: the first aproach worked for me, but how can i get the radius propertie value from the old physics body? can those properties be accessed (like friction, density, radius and bounce)?

Hi @thithous,

If you haven’t located it already, I suggest you start at Corona University for learning about physics (and other things as needed):

http://coronalabs.com/resources/tutorials/physics-box2d/

Properties like radius and friction are not directly read-able from a body… you’d need to just set them as properties of the object when you create it, then access those properties later.

Take care,

Brent