0
votes

Do anybody know how to apply transformation to sprite without opportunities of SpriteBatch.Draw() method ?

(Update from comments) This is what I need: I have a circle sprite. This picture contains shadows. I need to stretch this circle (make ellipse) and rotate it, but I want the shadow does not change its position into ellipse. Rotation and scaling change every frame. I think it's possible with matrix transformation

2
Your question doesn't make sense. Could you try rephrasing it? What are you trying to achieve? - Andrew Russell
I need: at first rotate sprite and then scale it. Method SpriteBatch.Draw() at first scales sprite and then rotates it. - Eugene Gluhotorenko

2 Answers

0
votes

The matrix passed into SpriteBatch.Begin is applied last. Using this is the only way to achieve a scale operation following a rotate operation through SpriteBatch (assuming your scale is non-uniform).

The downside is that, if the scale of each sprite is different, you will have to start a new batch for each.

Your other option is to write your own sprite batcher - but that seems a bit drastic.

0
votes

Thanks! I've found solution, but it is very slowly =(

this.displayMatrix = 
                Matrix.CreateTranslation(-(new Vector3(Position, 0))) * 
                Matrix.CreateRotationZ(1) *
                Matrix.CreateScale(new Vector3(new Vector2(1f, 2f), 1)) *
                Matrix.CreateTranslation((new Vector3(Position, 0)));