views:

127

answers:

1

Hi, I apply impulse in an object in box2d iPhone app and now want to increase its speed in particuler direction....i mean i need two thing

1.through the object in a direction 2.increase speed

plz help..

+1  A: 
b2Vec2 force = b2Vec2(xAcceleration, yAcceleration);
force *= dt;  // Use this if your game engine uses an explicit time step
b2Vec2 p = myObjectBody->GetWorldPoint(b2Vec2(0.0f, 0.0f));
body->ApplyForce(force, p);

By modifying xAcceleration and yAcceleration, you can make the object move with various speeds in different directions. (If you calculate angles, you might want to use force.Normalize(); and then multiply by a velocity.)

Felixyz
very very thanx......can u provide me the link of best books for box2diPhone..??i want to buy one..
Rony
but i have another question....i think in the above code p is the direction of force....isn't it??then if i want to direct it in X or -X or Y -Y axises then what to do??
Rony
plz look at..http://stackoverflow.com/questions/3385056/box2dgradually-increase-velocity-problem
Rony
Greetings Rony, your link, it does not work.
tomdemuyt