Box2d body movement in cocos2d-x

I need to move the box2d body in accordance with the position received from the game center server of the form.

After receiving the position, I simply update the position of the body using: -

   Carbody->SetTransform(b2Vec2(serverposition.x,serverposition.y),0);

But his body movement is inappropriate (for example, the body shows how someone appears on the screen). At the same time, my sprite image does not move (attached to the body).

+4
source share
1 answer

What I did to solve the positioning problem, I took a normal image of the sprite and just changed the position in the update with this position body2d.

For instance: -

. .     b2body userdata ()

carMainBody->SetTransform(b2Vec2(serverposition,carMainBody->GetPosition().y), 0.0f);

.

 car->setPosition(ccp(carMainBody->GetPosition().x*PTM_RATIO,carMainBody->GetPosition().y*PTM_RATIO));

.

+1

All Articles