Cannot flip image over x axes

171 Views Asked by At

I am using ggez rust crate, trying to develop 2d game. Currently I have a problem, where I want to flip image over x axes. So for example if character is looking in right direction, it would look left after transformation. Could not find anything useful in documentation. As I see DrawParam struct does not support this. Is there any way to achieve this?

1

There are 1 best solutions below

1
On BEST ANSWER

The Image struct has a method draw in where you can pass some DrawParams. DrawParams can set scaled or transformed which you could use for that.

You would just need to scale by a negative factor, something like:

image.draw(ctx, draw_params.scale(Vector2::from_slice(&[-1f32, 1f32])));