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