Cocos2d-x 3.0rc Physics

Hi,
I have just started physics game with cocos2d-x 3.0rc. I am having problem with function
m_world->setGravity(const Vect &gravity);
How can pass the vect to this function. I have tried different methods but all giving me errors. I am using xCode 5.0.2.
Thanks

Vect is a typedef of Point - at least it was in the Betas.
Point(float x, float y) and Vect(float x, float y) is therefor equal.

In turn, this means you can du this:
m_world->setGravity(Vect(0, -9.8f));
-9.8f is merely an approximation of earths gravity.

To clearify the syntax:
Vect gravity(0, -9.8f);
m_world->setGravity(gravity);

Btw, Vect is not std::vector<> if that’s what made the confusion :slight_smile:

Hope this helps you.

@LaE
Hi Thanks for reply. I have already tested these syntax.
xcode error mode takes me to this link
if (!_bodies.empty())

I have added the bodies also to the world. If I not setGravity, it works fine.
I just want to set the gravity (0,0).
Thanks

Oh my bad.
You have to set the gravity before setting the PhysicsWorld of the scene.
Here is the code for the future help .
`Scene* GamePlayScene::createScene(){

auto scene = Scene::createWithPhysics();

scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);

auto layer = GamePlayScene::create();
scene->getPhysicsWorld()->setGravity(Vect(0,0));
layer->setPhyWorld(scene->getPhysicsWorld());

scene->addChild(layer);

return scene;

}`

Regards