[monogame] Added more explicit example code for skeleton.PhysicsTranslate().

This commit is contained in:
Harald Csaszar 2024-04-16 17:37:05 +02:00
parent fb4f5b070d
commit e5aeb7ac29

View File

@ -314,8 +314,13 @@ namespace Spine {
state.Update(deltaTime);
skeleton.Update(deltaTime);
// Note: if you are not directly modifying skeleton.X or .Y, you can apply external
// physics movement via the following line:
// movement to physics via the following code:
// Vector2 lastPosition; // add as a member variable
// ..
// Vector2 currentPosition = <current world position>;
// Vector2 externalPositionDelta = currentPosition - lastPosition;
// skeleton.PhysicsTranslate(externalPositionDelta.x, externalPositionDelta.y);
// lastPosition = currentPosition;
state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);
@ -367,8 +372,13 @@ namespace Spine {
state.Update(deltaTime);
skeleton.Update(deltaTime);
// Note: if you are not directly modifying skeleton.X or .Y, you can apply external
// physics movement via the following line:
// movement to physics via the following code:
// Vector2 lastPosition; // add as a member variable
// ..
// Vector2 currentPosition = <current world position>;
// Vector2 externalPositionDelta = currentPosition - lastPosition;
// skeleton.PhysicsTranslate(externalPositionDelta.x, externalPositionDelta.y);
// lastPosition = currentPosition;
state.Apply(skeleton);
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);