• Runtimes
  • Monogame/XNA spine and camera transformation

Related Discussions
...

I'm using Camera2D from Monogame Extended, which applies a transformation matrix (translation and scale for zooming) to the spritebatch, and I need spine sprites to move and zoom with the camera.

Is there any way of applying the matrix to skeletonRender? What can I do to make the spine skeletons move and scale with camera other than manually updating the xy and scale in each update loop?

Thanks


I managed to solve this after looking at the source code for the runtime by adding this overload method for Begin() in SkeletonMeshRenderer.cs:

public void Begin(Matrix m) {
         defaultBlendState = premultipliedAlpha ? BlendState.AlphaBlend : BlendState.NonPremultiplied;

     device.RasterizerState = rasterizerState;
     device.BlendState = defaultBlendState;

     effect.Projection = m * Matrix.CreateOrthographicOffCenter(0, device.Viewport.Width, device.Viewport.Height, 0, 1, 0);
  }

SkeletonMeshRenderer and SkeletonRegionRenderer both expose the Effect instance used to render the skeleton as a property. You can set the transformation matrix on that effect.

ah I wasn't aware of that, I'm new to spine 🙂 It's better than editing the source for spine runtime

Thank you