Now my project included gravity for the world. But now you want to disable gravity for certain objects. Now I'm doing this:
void GameScene::initPhysics()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
world = new b2World(gravity);
// Do we want to let bodies sleep?
world->SetAllowSleeping(true);
world->SetContinuousPhysics(true);
}
Prompt how to turn off gravity for a particular object?
The b2Body class has a gravityScale
property. Call body->SetGravityScale(0.0)
on every body that you don't want to be affected by gravity.