Page 4 of 9

Re: [Library] anim8 - An animation library - v1.2.0 released

Posted: Wed Apr 03, 2013 7:33 pm
by Robin
Septi wrote:Is something wrong with anim8, or did I do something stupid? Please be forgiving, I'm very new both to Lua and Love.
I wouldn't call it stupid, but you need to change the first line to:

Code: Select all

local anim8 = require '3rdparty.anim8.anim8'

Re: [Library] anim8 - An animation library - v1.2.0 released

Posted: Sat May 04, 2013 12:25 am
by kikito
anim8 2.0.0 has been released. The new version is on github.

This release breaks backwards-compatibility significantly.

I've updated the OP with a changelog of the most important changes, and updated the demo to reflect them.

Regards!

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

Posted: Sat May 25, 2013 5:40 pm
by a7s1h1
Hi there!

I have just started dealing with animation and anim8 v2.0.0 is a very useful thing!
The issue which I'm now trying to settle is how to make the animation end be a condition.
I mean if I have, for example, such a grid:

Code: Select all

anim=anim8.newAnimation(image('1-18',1), 0.1)
, I'd like to be able to do something like that:

Code: Select all

if <animation ended, i.e. the frame of the current animation is 18 (or 1, if it pauses at start)> then
<code>
end
Will be thankful for any ideas.

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

Posted: Sun May 26, 2013 3:45 pm
by kikito
It is usually better to test for time, not for frames. I say this because an animation can be on its last frame without "ending" (for example, the last frame could take several seconds).

If you want to get the frame index, use anim.position:

Code: Select all

if anim.position == 4 then
  <do something when animation enters last frame>
end
I prefer using the "onLoop" function (new since 2.0). It is automatically invoked when an animation reaches the end of the last frame, instead of the beginning of its last frame. You can set it up when creating the animation:

Code: Select all

local anim = anim8.newAnimation(g('1-4',1), 0.1, function()
  <do something when animation last frame finishes>
end
You can also set it up after having created the animation:

Code: Select all

local anim = anim8.newAnimation(g('1-4',1), 0.1)
...
anim.onLoop = function()
  <do something when animation last frame finishes>
end

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

Posted: Mon May 27, 2013 11:07 am
by a7s1h1
onloop is just what I needed, thanks a lot!!! :awesome:

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

Posted: Fri Jun 07, 2013 2:59 pm
by a7s1h1
I'm facing one more issue.
There is some object, which has a random animation from time to time (just like in many platformer games, when you don't touch any key for a while). The problem is that sometimes my animation timer turns on at the time unknown to me and after it reaches 0, it triggers a new animation, so the current one is interrupted by a new one. I doublechecked all the pieces of my code to find that ugly trigger, but to no avail. Then I decided to put the condition before each time the timer is turned on, something like this:

Code: Select all

if <current animation (player.anim) is on> then
    player.timer=4
end
So, the question is "Is there any way to check if the animation is currently on or not?"

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

Posted: Sat Jun 08, 2013 6:34 pm
by kikito
Hi there,
a7s1h1 wrote:The problem is that sometimes <something happens but I don't know why>. I doublechecked all the pieces of my code to find that ugly trigger, but to no avail. Then I decided <to do something else which doesn't fix the issue, but masks it>
Every time you find yourself in that situation, stop. Usually masking the real issue is not a good solution. Keep chasing the problem, sleep on it, add lots of prints, or even rewrite the whole thing, until you understand clearly what the issue is. Don't bury it with more code that masks the issue. You would be just laying traps for your future self.

It's good to spend time getting the foundations right, before building on top of them; otherwise when the house is half-built, it'll collapse.
a7s1h1 wrote:So, the question is "Is there any way to check if the animation is currently on or not?"
Well, it depends on what you mean by "on". If you mean "playing", yes, you can check that by doing if anim.status == "playing" then [...] .

However I don't recommend it. The reason is that you would be using animations for something they are not designed for.

Animations should change according to what your code tells them, like this:

Code: Select all

if player:isDying() then
  player.dyingAnimation:setFrame(1)
  player.setAnimation(player.dyingAnimation)
end
You are trying to do it the other way around - the animation is controlling your code.

Code: Select all

if anim.status == "playing" then
  <other game code>
end
Let me use an analogy. Imagine that you are doing a platformer, where the player is mostly green and the platforms are mostly red. If you coded it the way you are attempting to use animations, you would be drawing the player and the platforms on the screen, and then reading some pixel colors from the screen to detect if the player was on a platform (instead; you should use the player and platform coordinates and detect how they collide with maths).

I strongly recommend going back to your code and understanding what really happens there. If you need help, I recommend opening a post in the support forum and putting a *.love file there, so others can help you (please don't upload it directly on this thread, since it seems that anim8 is not your real problem here).

In any case, good luck solving your issues!

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

Posted: Mon Dec 16, 2013 6:57 pm
by kikito
I have released anim8 v2.1.0. The only thing it adds is compatibility with LÖVE 0.9. I've updated the OP with the details.

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

Posted: Tue Dec 17, 2013 5:51 pm
by pacman
Great! <3
Now I only need Advanced Tile Loader 0.9 : 3 :

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

Posted: Tue Dec 17, 2013 5:57 pm
by MadByte
pacman wrote:Great! <3
Now I only need Advanced Tile Loader 0.9 : 3 :
here, does work for me.