[Solved]How to mirror an AnAL animation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
zooks97
Prole
Posts: 11
Joined: Wed Jan 01, 2014 6:22 pm
Location: United States

[Solved]How to mirror an AnAL animation

Post 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:
Last edited by zooks97 on Sat Jan 04, 2014 4:01 pm, edited 1 time in total.
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: How to mirror an AnAL animation

Post 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.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: How to mirror an AnAL animation

Post 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.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
zooks97
Prole
Posts: 11
Joined: Wed Jan 01, 2014 6:22 pm
Location: United States

Re: How to mirror an AnAL animation

Post by zooks97 »

Yes, it does work in 0.9.x; that's what I'm using it in.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: [Solved]How to mirror an AnAL animation

Post by Ranguna259 »

Awesome, I thought it used some kind of quad technique to sort the frames in the animations.

Thanks for the info :nyu:
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests