Chipmunk: change radius of CircleShape

Hi, I need to change the radius of the CircleShape of the body of a PhysicsSprite after collition.
Framework: Cocos2d-js v3.6.1

In the process of creating the sprite I store a reference of it’s CircleShape on a variable spShape.

Setting the value of the shape like this:
spShape.r = NEW_R;
Works on browser, but not on IOS or Android

I also tried to remove the shape of the body and add a new shape, but the new shape generates no collision:

body.removeShape(spShape); //only browser version supports this method
space.removeShape(spShape);
spShape = new cp.CircleShape(body, NEW_R, 0);
spShape.elasticity = 1;
spShape.friction = 0;
spShape.setSensor(false);
spShape.setCollisionType(2);
space.addShape(spShape);

cc.log(spShape.r) gives me NEW_R (>0)

I tried all these after the space step.

I have not tried replacing PhysicsSprite by a Sprite and a body, and so, removing the whole body and creating a new one with a CircleShape with r=NEW_R. The problem with that is that I would lose the impulse of the old body, generated by the collision.

Thanks

You need to delete and re create a new circle shape and re attach it.

Didn’t work, I had to separate the PhysicsSprite into a sprite and a body, and remove the body, and create a new one with a new shape

Why don’t just change the scale ?

I’m using cocos2d-js, All worked ok on browser, but for native there is no way to change the scale of the shape of the PhysicsSprite shape. When I change the scale of the PhysicsSprite, the shape doesn’t scale.

For example, for browser setting the radius of the shape with shape.r = R, works fine, but when publishing to IOS or Android, it does not.

I’m suggesting to change the scale and not the radius, it should work