1
votes

I'm drawing a tile-based game. Some tiles can rotate, about their centre. It appears that setting a rotation origin for one SpriteBatch.Draw call effects all other Draw calls with no origin specified.

Is there a way to avoid having to speficy the origin for every other draw call for non-rotating tiles?

Ideally i don't want to have to batch drawing my non-rotating tiles together and draw before/seperately to my rotating tiles.

1

1 Answers

2
votes

It appears that setting a rotation origin for one SpriteBatch.Draw call effects all other Draw calls with no origin specified.

This is simply not the case. The origin for Draw applies only to that particular Draw.

If you are using an overload of Draw that does not specify an origin, an origin of Vector2.Zero is implicitly used.

Now, if you are actually passing a matrix to Begin, that matrix will be applied to all Draw calls (including ones where you set an origin) on that particular sprite batch until its End method is called.

You should use the rotation parameter of Draw to rotate individual sprites in your world. You should use the matrix parameter on Begin to move the view of all of your sprites around (like a camera).