Я не очень хорошо знаком с целью-c, но попробую.
Все, что я вижу, это то, что вы сохраняете указатель на объект спрайта в пользовательских данных тела и затем оставляете его там. Если вы хотите, чтобы положение тела было перенесено в спрайт, вам нужно обновлять его каждый кадр.
В C ++ это будет выглядеть примерно так:
// To be called each time physics should be updated.
void physicsStep(float32 timeStep, int32 velocityIterations, int32 positionIterations) {
// This is the usual update routine.
world.Step(timeStep, velocityIterations, positionIterations);
world.ClearForces();
// SpriteClass can be replaced with any class you favor.
// Assume there is a known pointer to the b2Body. Otherwise you'll have to get that,
// or iterate over all bodies in the world.
SpriteClass *sprite = (SpriteClass*)body->GetUserData();
// Once you have the pointer you can transfer all the data.
sprite.position = body->GetPosition();
sprite.angle = body->GetAngle();
// ... and so on
}
Пользовательские данные - это произвольное пространство для хранения в b2Body, и Box2D не имеет представления о том, что вы решили там хранить.