1

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));

}
Shiva Yadav
  • 72
  • 1
  • 9
  • m using cocos2dx 3.17.1 and am using "sprite->getPhysicsBody()->setVelocity(x,y)" but sprite moves like it is flying in the air no friction and all – Shiva Yadav May 02 '20 at 06:36
  • Use forces and impulses and let the engine determine the physics. Why use a physics engine at all, if you're not going to let it do what it does? – molbdnilo May 02 '20 at 06:43
  • What do you mean by *sprite moves like it is flying in the air*? That there is gravity? Remove gravity globally, or make the object not sensitive to. – Jean-Baptiste Yunès May 02 '20 at 07:49
  • there is no gravity , and how can i make the object not sensitive to , also there is no friction from ground and the sprite moves like it is very light in weight – Shiva Yadav May 02 '20 at 11:04

0 Answers0