[3.0beta2] change physics body issue

the sprite have PhysicsBody.i try to remove the old body and set the new one.the second time setPhysicsBody is not work.
BTW : how to change the individual body’s gravityScale in chipmunk ?i used the box2d before.Box2d had setGravityscale method.

It can’t set different gravity for each one, I think you can use applyForce to simulate it.
Is this gravityScale useful? I will add this api if it is useful.

thx . i will try applyForce
gravityScale is userful for my project i think…pls add that api .thank you so much!:slight_smile: :slight_smile:

and another question
for example:

Sprite* testSprite = Sprite::create("rock_01.png");
testSprite->setTag(1);
testSprite->setPosition(Point(350, 600));
PhysicsBody* sprite1Body = PhysicsBody::create();
PhysicsShapeBox* firstBoxSprite = PhysicsShapeBox::create(Size(testSprite->getContentSize()));
sprite1Body->addShape(firstBoxSprite);
sprite1Body->setDynamic(false);
testSprite->setPhysicsBody(sprite1Body);
 addChild(testSprite);

onTouchBegan event method

Sprite* testSprite = (Sprite*)getChildByTag(1);
testSprite->setColor(Color3B(0, 255, 0));
PhysicsBody* tmp =  testSprite->getPhysicsBody();
tmp->removeFromWorld();
PhysicsBody* sprite1Body2 = PhysicsBody::create();
PhysicsShapeBox* secondBoxSprite = PhysicsShapeBox::create(Size(testSprite->getContentSize()));
sprite1Body2->addShape(firstBoxSprite);
sprite1Body2->setDynamic(false);
testSprite->setPhysicsBody(sprite1Body);

so when i touch .the sprite be green and physicsbody be removed .but the new one physicsbody not be added.

Yes, Bug conformed.
I created a issue here:
http://www.cocos2d-x.org/issues/4144
I will fix it soon.

thx so much!:slight_smile:

But fixed.
PR link: https://github.com/cocos2d/cocos2d-x/pull/5467

I created an issue for PhsycisBody::setGravityScale().
http://cocos2d-x.org/issues/4425