Hi All,
I have a Ball and I want to apply force at the bottom of the ball every time when I tap on the screen.
I tried following code:
With the above code I am able to apply force to ball which is on the ground but the problem is if I tap more number of time
it appears like applying force at the top of the ball.
Even I tried following but same results.
Any help is really appreciated.
Thanks,
Madhu.
I have a Ball and I want to apply force at the bottom of the ball every time when I tap on the screen.
I tried following code:
Code:
b2Vec2 ball_body_position = ballBody->GetPosition();
b2Vec2 ball_force_apply_pos;
ball_force_apply_pos.x = ball_body_position.x;
ball_force_apply_pos.y = ball_body_position.y - ballRadiusInMeters;
ballBody->ApplyForce(b2Vec2(0.0, 6.0), ball_force_apply_pos);
b2Vec2 ball_force_apply_pos;
ball_force_apply_pos.x = ball_body_position.x;
ball_force_apply_pos.y = ball_body_position.y - ballRadiusInMeters;
ballBody->ApplyForce(b2Vec2(0.0, 6.0), ball_force_apply_pos);
With the above code I am able to apply force to ball which is on the ground but the problem is if I tap more number of time
it appears like applying force at the top of the ball.
Even I tried following but same results.
Code:
ball_force_apply_pos.y = ball_body_position.y + ballRadiusInMeters;
Any help is really appreciated.
Thanks,
Madhu.