Page 1 of 9

[Library] anim8 - An animation library - v2.3.0 released

Posted: Fri Mar 02, 2012 12:38 am
by kikito
Hi there,

EDIT: I have just released anim8 v2.1.0. The only thing that changes in this version is LÖVE 0.9 compatibility.

Anim8 is always available on github:

https://github.com/kikito/anim8

So - what is this lib?

Its aim is making animations in a single call, in a human-friendly way - minimizing the amount of typing, when possible.

One way of reducing the amount of typing was "splitting" the information in two parts. The first part, I called "Grids", and basically are heavy-duty "Quad creators". Once a grid is created, I initially tought of specifiying the frames of an animation like this:

Code: Select all

grid({1,1}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7})
This is a lot of typing. I decided to leave the brackets out:

Code: Select all

grid(1,1, 1,2, 1,3, 1,4, 1,5, 1,6, 1,7)
That's better, but could be reduced further. For example, it's a very usual case that animations are "rows" or "columns" in the spritesheet. So I decided to allow using strings to define intervals. In anim8, the previous code can also be compressed to the following two params:

Code: Select all

grid(1,"1-7")
Of course, that style can be "mixed up" with numbers. This is equivalent to the previous line:

Code: Select all

grid(1,"1-6", 1,7)
Another feature I'm proud of is that grids can handle frame borders, or "offset", very easily - once you define those in the grid, it's just "transparent".

Once you have the frames(aka quads) you want, you just pass them on to the "animation". Although very convenient, you don't need to use a grid to provide the animation with the quads; you can create them by other means if you so wish. I recommend using grids whenever possible, because quads are "reused" aggressively; the lib never creates the same quad twice; it "caches" all quads in case it wants to reuse them.

Please give the demo and the README in github a look. Let me know if you have questions or find any bugs!

Attaching demos for LÖVE 0.8 / anim8 2.0 and LÖVE 0.9 / anim8 2.1
anim8-demo.love
v0.8.0-compatible demo
(64.2 KiB) Downloaded 1308 times
anim8-demo-0.9.love
v0.9.0-compatible demo
(64.31 KiB) Downloaded 1375 times
anim8-demo-0.10.love
v0.10.0-compatible demo
(64.38 KiB) Downloaded 1034 times
Changelog:

v2.3.0
  • Adds support for shearing (kx, ky parameters when drawing)
  • Adds Animation:getFrameInfo()
v2.2.0
  • Adds Animation:getDimensions()
v2.1.0
  • LÖVE version upped to 0.9.x

Re: [Library] anim8 - A different animation library

Posted: Fri Mar 02, 2012 3:28 am
by jradich
http://www.youtube.com/watch?v=YKUOB8MN4Kc
I like this. I'll actually be able to do animation stuff.

Re: [Library] anim8 - A different animation library

Posted: Fri Mar 02, 2012 12:42 pm
by Shooby
Great, thanks a bunch! I love all the libraries you have made so far.

It would seem like there is a tiny mixup in the GitHub documentation:

Code: Select all

anim8.newAnimation(mode, defaultDelay, frames, delays)
Should probably be:

Code: Select all

anim8.newAnimation(mode, frames, defaultDelay, delays)
Confused me for a moment :crazy:

Edit: Oh, you did mention the documentation was still in progess. My bad.

Re: [Library] anim8 - A different animation library

Posted: Fri Mar 02, 2012 4:59 pm
by kikito
Indeed. I have finished the doc just now. I'm updating the OP.

EDIT: updated, with new demo and descriptions.

Re: [Library] anim8 - A different animation library

Posted: Wed Mar 14, 2012 4:37 pm
by tsturzl
Cool library, basically solved the only problem I had with AnAL.

Often times the sprite sheets my artist make end up having one or two blank spaces. I also thinks its pretty nifty to put more than one animation on a sprite sheet.

I like the fact that you simplified the grid function too, setting that many arguments every time you create an animation would be agonizing.

Perhaps a cool feature would be if you set the speed to negative it would play in reverse.

Re: [Library] anim8 - A different animation library

Posted: Wed Jun 13, 2012 2:56 pm
by kexisse
anim8 saved me a bunch of time. Thanks for making it!

I have a question though, how would it be best to modify the delays on-the-fly?
I'm imagining that my animation would play faster as my character runs faster (kind of like Mario).

Re: [Library] anim8 - A different animation library

Posted: Wed Jul 04, 2012 3:07 pm
by AlexBryant
Excuse me for being a noob, but as I'm entirely new to Love, is there a tutorial for this? And where do you put the anim8 script?

Re: [Library] anim8 - A different animation library

Posted: Wed Jul 04, 2012 9:23 pm
by kikito
Hi AlexBryant, welcome!
is there a tutorial for this?
The nearest thing I know is the Readme that comes with anim8, but it's meant to be read by someone who is already familiar with at least the basics of Löve and Lua. I recommend you to learn those first. For those, I do have a tutorial - https://github.com/kikito/love-tile-tutorial/wiki (Start on Chapter 0 - Basic Stuff).
And where do you put the anim8 script?
You can put it next to main.lua . Then you require it in main.lua doing this:

Code: Select all

-- this goes in main.lua
local anim8 = require 'anim8'
That is the way it is used in the demo file, attached on the first post. If you are curious, change its extension from .love to .zip and you will be able to open/uncompress it (love files are zip files with their extension changed).

Re: [Library] anim8 - A different animation library

Posted: Tue Sep 18, 2012 8:41 am
by kikito
kexisse wrote:I have a question though, how would it be best to modify the delays on-the-fly?
I apologize - I didn't see this question before.

Animations have a public attribute called "delays". It's a simple table of numbers, one per frame. If you need to, you can modify that table manually. There is no way to do that "nicely" - I might add it.

Re: [Library] anim8 - A different animation library

Posted: Thu Sep 27, 2012 12:45 pm
by clofresh
I love anim8! Makes animation so much easier.

Question: Is there a way to ask an animation for the bounding box of the non-transparent area of the current frame? It'd like to use it for collision detection where collisions correspond directly to the drawn pixels, but a grid cell is the size of the largest animation frame so many frames have a padding of transparent pixels to make them uniform size. Doesn't have to be the exact shape, a rectangle would do fine.