Flipping 2D Sprites

I was looking for any ideas about how to flip 2D sprites when changing direction.

I’m making a 2D platformer and the sprites I’ve drawn for it are all facing to the right.

I’ve looked up online for a inexpensive way to try and “flip” these sprites when they are moving to the left, so that whatever their animation or sprite is will now be in reverse.

I came across the “Flipped” enum component (https://docs.rs/amethyst_renderer/0.10.4/amethyst_renderer/enum.Flipped.html) but I don’t think this is part of the latest amethyst code (I can’t access the enum when using amethyst::renderer).

Does anyone have any ideas or examples they could point me towards please?

Any help would be very appreciated.

Cheers.

You can rotate the sprites around the y-axis by either zero or pi radians:

        // Flip sprite if character is facing left:
        transform.set_rotation_y_axis(if steering.facing.x == Direction1D::Negative {
            f32::PI()
        } else {
            0.
        });
1 Like

Awesome thanks for your help Jazarro.

1 Like