verilog is on the right track.
If you look at the
animation:draw() function, you will see that it has lots of parameters (most of them optional):
Code: Select all
function Animation:draw(image, x, y, r, sx, sy, ox, oy)
If the parameters sx and sy allow you to flip images, just like in the love.graphics.draw. So you can do this:
Code: Select all
animation:draw(image, x, y, 1, -1, 1) -- flip horizontally
animation:draw(image, x, y, 1, 1, -1) -- flip vertically
animation:draw(image, x, y, 1, -1, -1) -- flip horizontally and vertically
This is now a well-rounded solution. Depending on how your animations are drawn, it might not look right. In particular, some walking animations will look "as if the character was doing the
moonwalk" if you simply flip their images.
For those, you will have to create a different animation with the frames in inverted order. Anim8 doesn't have a method to "create an animation with the frames in opposed order", because "opposed order" is a subjective term. But creating it with the grids system should be very simple.
Code: Select all
walkLeft = anim8.newAnimation(g('1-5,1'), 0.1)
walkRight = anim8.newAnimation(g('5-1,1'), 0.1) -- same frames in opposite order
...
walkLeft:draw(image, x, y)
walkRight:draw(image, x, y, 1, -1, 1) -- flipped frames horizontally
Then you can draw the animation with the images flipped, and they should look alright.
EDIT: I've decided to
open up an issue in anim8 to investigate this further. Maybe adding one or two methods related with image flipping could benefit everyone. For now, the workaround I'm proposing is the best there is.