Skip to content

Commit

Permalink
[monogame] Adjusted existing monogame code and examples to 4.2 physics.
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldCsaszar committed Mar 28, 2024
1 parent 5631eb9 commit 37014e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 11 additions & 5 deletions spine-monogame/spine-monogame-example/ExampleGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public override void Render (float deltaTime) {
// to the skeleton
state.Update(deltaTime);
state.Apply(skeleton);
skeleton.Update(deltaTime);

// Update the transformations of bones and other parts of the skeleton
skeleton.UpdateWorldTransform();
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);

// Clear the screen and setup the projection matrix of the skeleton renderer
game.GraphicsDevice.Clear(Color.Black);
Expand Down Expand Up @@ -143,8 +144,9 @@ public TankScreen (Example game) : base(game) {
public override void Render (float deltaTime) {
state.Update(deltaTime);
state.Apply(skeleton);
skeleton.Update(deltaTime);

skeleton.UpdateWorldTransform();
skeleton.UpdateWorldTransform(Skeleton.Physics.Update);

// Clear the screen and setup the projection matrix of the custom effect through the
// "Projection" parameter.
Expand Down Expand Up @@ -200,7 +202,9 @@ public SpineboyScreen (Example game) : base(game) {
public override void Render (float deltaTime) {
state.Update(deltaTime);
state.Apply(skeleton);
skeleton.UpdateWorldTransform();
skeleton.Update(deltaTime);

skeleton.UpdateWorldTransform(Skeleton.Physics.Update);

game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);
Expand Down Expand Up @@ -229,7 +233,7 @@ public MixAndMatchScreen (Example game) : base(game) {
SkeletonJson json = new SkeletonJson(atlas);
json.Scale = 0.5f;
SkeletonData skeletonData = json.ReadSkeletonData("data/mix-and-match-pro.json");

skeleton = new Skeleton(skeletonData);
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
Expand Down Expand Up @@ -259,7 +263,9 @@ public MixAndMatchScreen (Example game) : base(game) {
public override void Render (float deltaTime) {
state.Update(deltaTime);
state.Apply(skeleton);
skeleton.UpdateWorldTransform();
skeleton.Update(deltaTime);

skeleton.UpdateWorldTransform(Skeleton.Physics.Pose);

game.GraphicsDevice.Clear(Color.Black);
((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0);
Expand Down
6 changes: 6 additions & 0 deletions spine-monogame/spine-monogame/spine-monogame.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<Compile Include="..\..\spine-csharp\src\IkConstraintData.cs">
<Link>spine-csharp\IkConstraintData.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\PhysicsConstraint.cs">
<Link>spine-csharp\PhysicsConstraint.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\PhysicsConstraintData.cs">
<Link>spine-csharp\PhysicsConstraintData.cs</Link>
</Compile>
<Compile Include="..\..\spine-csharp\src\IUpdatable.cs">
<Link>spine-csharp\IUpdatable.cs</Link>
</Compile>
Expand Down

0 comments on commit 37014e9

Please sign in to comment.