Page 1 of 1

[Solved]How to mirror an AnAL animation

Posted: Fri Jan 03, 2014 3:08 am
by zooks97
I'm making a platformer and I have a character comprised of 3 animated parts: arm, body, face. The frames for the animations of each part are in their own spritesheets and are animated using AnAL. I'm not sure how to mirror the animations when turning from left to right (the textures face left), and I'm not sure how to change from the idle animations to the walking animations. All of the tutorials and threads I've seen so far use drawn images (using löve's draw function) and aren't animated or are animated using something other than AnAL.
For the walking / idle animation switch, I've tried stopping the idle animation and starting the walking one under the love.keyboard.isDown, but that just stopped the idle animation even when the button wasn't down and when the button was down, the new one didn't start. A similar thing happened with love.keypressed.

Download:https://dl.dropboxusercontent.com/u/116 ... rySP5.love

Thanks in advance :awesome:

Re: How to mirror an AnAL animation

Posted: Fri Jan 03, 2014 1:03 pm
by OmarShehata
You're already drawing the "stand" animation, and commenting out the walking one. And if you comment out the stand, and leave the walking, then the character walks, right?

So all I did was make a variable "walking", which is set to false every frame, and if either the right or left key is pressed, it gets set to true. Here's the edited main.lua: http://pastebin.com/zySvcFzN

As for flipping the animation, you said that every tutorial and thread you've seen using love's normal draw functions, not AnAL's, but there's virtually no difference.

This is the draw function in AnAL.lua

Code: Select all

--- Draw the animation
local drawq = love.graphics.drawq or love.graphics.draw
function animation:draw(...)
	return drawq(self.img, self.frames[self.position], ...)
end
So all it really does is take whatever arguments you give it and passes it to the draw function. You're drawing your objects by draw(x,y), you can add draw(x,y,angle,scaleX,scaleY) and so on. Adding a negative scaleX will flip the animations.

Re: How to mirror an AnAL animation

Posted: Fri Jan 03, 2014 6:13 pm
by Ranguna259
AnAL is not comptible with 0.9.0 anymore, right ?
I haven't had the time to test it in the new version but if it's not compatible then I'm going to have a hard time with my old animation codes.

Re: How to mirror an AnAL animation

Posted: Fri Jan 03, 2014 6:40 pm
by zooks97
Yes, it does work in 0.9.x; that's what I'm using it in.

Re: [Solved]How to mirror an AnAL animation

Posted: Sat Jan 04, 2014 4:55 pm
by Ranguna259
Awesome, I thought it used some kind of quad technique to sort the frames in the animations.

Thanks for the info :nyu: