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

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
konacake
Prole
Posts: 11
Joined: Mon Mar 03, 2014 4:35 am

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by konacake »

Ah, thank you kikito, I finally get it. Honestly I prefer to put in the coordinates in manually, rather than using your string shortcut, but it is a nice feature once you get used to it. Thanks again for the work you put in to all your wonderful libraries, you make the best ones.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by s-ol »

I think it would be nice if every (x, y) pair would be one string:

"1, 2"
"2-3, 2"
"5, 4-7"
"2-3, 9-10"

then dealing with the varargs would get easier in trade for slightly more complex parsing (split at comma, tonumber() if theres no dash).
I think that looks a lot cleaner, mixing strings and numbers always felst (slightly) dirty for some reason.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by kikito »

It was like that initially, but I removed it later on. Almost always it's the same amount of characters, and it simplifies the parsing quite a lot.
When I write def I mean function.
User avatar
SouL
Prole
Posts: 14
Joined: Mon Jun 30, 2014 1:33 pm

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by SouL »

Hello.

What would be the approach to accomplish the following:

I have a button and a sprite with two movements. The attack movement and the idle movement. The sprite is always being animated with the idle movement. When I click the button, I want to change the animation to the attack one and when finishing the attack, return to the idle animation.
Also, is possible to get the exact moment of the end of the attack to trigger another event?


Thanks for any answer, I'm really new into Löve and Lua.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by s-ol »

SouL wrote:Hello.

What would be the approach to accomplish the following:

I have a button and a sprite with two movements. The attack movement and the idle movement. The sprite is always being animated with the idle movement. When I click the button, I want to change the animation to the attack one and when finishing the attack, return to the idle animation.
Also, is possible to get the exact moment of the end of the attack to trigger another event?


Thanks for any answer, I'm really new into Löve and Lua.
For the end of the attack, you can put an "onLoop" function:

Code: Select all

animation.onLoop = function () -- do something end
for multiple animations, here is what I usually do:

Code: Select all

function Player.new()
  local self = {} -- whatever you are doing here
  
  self.idle     = IDLE_ANIM:clone() -- the anim8 idle animation
  self.attack = ATTACK_ANIM:clone()
  self.attack.onLoop = function () self:attackDone() end
  self.anim   = self.idle

  return self
end

function Player:update(dt)
  self.anim:update(dt)
  
  if not self.attacking and love.keyboard.isDown" " then
    self.attacking = true
    self.anim = self.attack
  end
end

function Player:draw()
   self.anim:draw()
end

function Player:attackDone()
  -- do something
end

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by bobbyjones »

Does anim8 support spritebatches?

Edit: If it doesn't I could add that in this weekend and submit a PR. Although the api probably would have to be changed to reflect that.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: [Library] anim8 - An animation library - v2.1.0 released

Post by kikito »

I am releasing anim8 v 2.3.0 today!

It adds a couple things:

* spritebatch support (thanks to bobbyjones and zorggn for their invaluable feedback in resolving this)
* better handling of the shear factor params (kx,ky) when drawing / blitting to a spritebatch

I have also written a small demo showing spritebatches and shearing working together. It can be found on the spritebatch-demo branch: https://github.com/kikito/anim8/tree/spritebatch-demo
When I write def I mean function.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post by zorg »

In all honesty, you did most of the work, so thanks to you, kikito! :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

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

Post by bobbyjones »

Yay, but as zorg said, I did nothing but complain lol.

edit: 500th post \o/
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

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

Post by Jack Dandy »

Hey there, first off- THANKS very much for this cool, handy library!

Now, I have a question.
In the readme in https://github.com/kikito/anim8, it says:
onLoop is an optional parameter which can be a function or a string representing one of the animation methods. It does nothing by default. If specified, it will be called every time an animation "loops". It will have two parameters: the animation instance, and how many loops have been elapsed. The most usual value (apart from none) is the string 'pauseAtEnd'. It will make the animation loop once and then pause and stop on the last frame.
Now, let's say I supply my own little function.
But I don't exactly understand, how am I supposed to access the two parameters you talked about in the quote?

For example, the following didn't work.

Code: Select all

slashAnim = anim8.newAnimation(animgrid('1-6',1), 0.04, (function(a,b) DRAWSLASH=false  a:pauseAtEnd() end))
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests