This is a sample code to move a body in Box2D .
First you have to make a body with variable name “moving_rec” and call the below function in a schedular at regular intervals.
-(void) moveBody{ b2Vec2 force = b2Vec2(0,0); force = b2Vec2(0,3); //Giving the x an y to negative will move the body in opposite direction. moving_rec->SetLinearVelocity(force); //set Linear velocity for moving in a constant speed. }
Please leave your comments on this post.