How to change direction of Gravity on runtime?

It would be really interesting to change the direction of gravity on different times throughout the game…
But It needs some research, I might answer soon, anyone would be welcome to solve.

auto world = _director->getRunningScene()->getPhysicsWorld();
world->setGravity(Vec2(0,-10));
1 Like

Thread Solved, I was searching for cc.v2(x,y) for weeks,

Here’s the code if you’re curious,
cc.director.getPhysicsManager().gravity = cc.v2(x,y);

single line.

1 Like