I'm toying around with Flame game engine and am finding it difficult to flip the sprite. Most game engines/libraries allow you to do this by multiplying the x scale by -1. However, this does not work with the spritesheet/spriteanimation classes' size variable. What is considered the proper way to flip a sprite in flutter flame?
Update for Flame >v1.4.0:
Any component that extends PositionComponent
(which all of the ones you listed do) you can use the flipHorizontally()
and flipVertically()
methods to flip your components.
Old answer:
On any component that extends PositionComponent
(which all of the ones you listed do) you can just set renderFlipX = true
or renderFlipY = true
on the component and it will render flipped.
If you want to do this on a pure sprite, which doesn't seem like what you want to do but I'll mention it here anyways, you have to override the render
method and flip the canvas before calling super
and then restore it afterwards.