Search code examples
cocos2d-xbox2d

Gradually slowing down linear velocity of box2d body


I am currently developing a billiard game using box2d physics engine. When I apply force to main ball, it will gain constant speed.

How to gradually slow the body?

P.S. Gravity is set to zero


Solution

  • Set linear damping to that body. Lets say 5

    body->setLinearDamping(5);