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.
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:
-9.8f is merely an approximation of earths gravity.
To clearify the syntax:
Vect gravity(0, -9.8f);
Btw, Vect is not std::vector<> if that’s what made the confusion
Hope this helps you.
Hi Thanks for reply. I have already tested these syntax.
xcode error mode takes me to this link
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).
Oh my bad.
You have to set the gravity before setting the PhysicsWorld of the scene.
Here is the code for the future help .
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;