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?
Asked
Active
Viewed 127 times
1

Sharmiko
- 543
- 4
- 21
1 Answers
1
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])));

Netwave
- 40,134
- 6
- 50
- 93
-
Did not know scale could be used like that. It solves my problem. Thanks a lot. – Sharmiko May 19 '22 at 14:26