开发者

RotateFlip - when it is applied?

I'm using RotateFlip to flip sprites horizontally. It seems that RotateFlip is applied when Graphics is drawn not image.

The problem is that some sprites needs to be flipped and some not (depending on direction of sprite). I don't wa开发者_如何学JAVAnt to clone image each time I'm drawing flipped sprite.


Consider using a transformation matrix on the Graphics object instead of using RotateFlip on the image. Flipping is equivalent to scaling the X or Y coordinates by -1. You can pre-compute a single flip matrix and use it whenever you want:

Matrix flipX = new Matrix();
flipX.Scale(-1, 1);

graphics.Transform = flipX;
// Draw your sprite here
graphics.ResetTransform();

Note however that you will have to pass in modified coordinates when drawing, for eg. using the above transform, you'll have to pass in ContainerWidth - X instead of X.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜