how can i add velocity and friction to my physics bodies in cocos2dx

132 Views Asked by At

I want to move my carroms on hitting of the striker am using simple setVelocity but it looks like my carroms coins are floating in air on carrom board so plz help me to move smoothly them carrom board velocity of carroms

void GameScene::adjustStrikerVelocity() {

  strikerSprite->getPhysicsBody()->setDynamic(true);

  float x = start.x - ( origin.x + strikerSprite->getPositionX() );
  float y = start.y - ( origin.y + boardSprite->getPositionY( ) - boardSprite->getContentSize().height/2 + strikerSprite->getPositionY( ) );

  strikerSprite->getPhysicsBody()->setVelocity( Vec2( x * powerBooster, y * powerBooster ) );
  strikerSprite->getPhysicsBody()->applyForce(Vec2(100,100),Vec2::ZERO);
  strikerSprite->getPhysicsBody()->setVelocityLimit(400);
  strikerSprite->getPhysicsBody()->setLinearDamping(0.5);

  this->schedule(schedule_selector(GameScene::checkPuck));

}
0

There are 0 best solutions below