having trouble with applyImpulse(Vect()) in cocos2dx 3.0 beta2 ???

having trouble with applyImpulse(Vect()) in cocos2dx 3.0 beta2 ???
0

#1

Hi all I don’t know I did anything wrong. After creating scene with physics (follow this http://www.cocos2d-x.org/docs/manual/framework/native/physics/physics-integration/en ), My target is to make the ball to move with the same speed in a “rectangle cage” as in a game Breakout. Here is my code
ball = Sprite::create(“ball.png”);
ball->setPosition(visibleSize.width/2 + origin.x,visibleSize.height/2 + origin.y);
auto ballBody = PhysicsBody::createCircle(ball->getContentSize().width/2);

ballBody->setDynamic(false);

//ballBody->setGravityEnable(false);
ball->setPhysicsBody(ballBody);
ball->getPhysicsBody()->applyImpulse(Vect(10,-10));

this->addChild(ball);`

`

Run -> the ball doesn’t move …


#2

Not used 3.0 beta2, but if you don’t set the physics body to dynamic there is no way you will make it move via an applied impulse. Static (no-dynamic) bodies have an effective infinite mass.


#3

thank, IslandPlaya. wow, I set the physics body dynamic but the ball fall !!!