[Library] anim8 - An animation library - v2.3.0 released
Re: [Library] anim8 - An animation library - v2.1.0 released
You are all golden :*
Re: [Library] anim8 - An animation library - v2.1.0 released
hi
how do you tell the grid/animation to play the frames in a specific order ?
as in:
- a sprite of 3 by 3
i want to start at the bottom left, 1, and then move sequentially through the sprite.
how do you tell the grid/animation to play the frames in a specific order ?
as in:
Code: Select all
[3], [6], [9]
[2], [5], [8]
[1], [4], [7]
i want to start at the bottom left, 1, and then move sequentially through the sprite.
- 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
You need an animation that:zell2002 wrote:hi
how do you tell the grid/animation to play the frames in a specific order ?
as in:
Code: Select all
[3], [6], [9] [2], [5], [8] [1], [4], [7]
- For the first 3 frames, leaves X=1 and moves Y from 3 to 1
- For next 3 frames, leaves X=2 and moves Y from 3 to 1
- For the last 3 frames, leaves X=3 and moves Y from 3 to 1
Code: Select all
local g = anim.newGrid(32, 32, 256, 256)
local fancyAnimation = anim.newAnimation(g(1,'3-1', 2,'3-1', 3,'3-1'), 0.1)
- You will need to replace the newGrid params with the right frame & image dimensions.
- You will also probably need to tweak the frame durations (the 0.1)
- That kind of order is unusual, the usual one starts from left to right, and then goes from top to bottom. This is the order that anim8 follows by default. If you rearrange your frames so they look like this:
Code: Select all
[1], [2], [3]
[4], [5], [6]
[7], [8], [9]
Code: Select all
local fancyAnimation = anim.newAnimation(g('1-3', '1-3'), 0.1)
When I write def I mean function.
Re: [Library] anim8 - An animation library - v2.1.0 released
lol ye the order is VERY odd. ive seen a few like this (i didnt make it)
i would have made it like any sane person - top left to top right.
i think i will edit it.
cheers for the info! that will be most useful (will test it now so ive got the understanding under my belt)
i would have made it like any sane person - top left to top right.
i think i will edit it.
cheers for the info! that will be most useful (will test it now so ive got the understanding under my belt)
- CaptainMaelstrom
- Party member
- Posts: 163
- Joined: Sat Jan 05, 2013 10:38 pm
Re: [Library] anim8 - An animation library - v2.1.0 released
Hey kikito. I'm having some issues with anim8 .
1.) The github wiki mentions that the "onLoop" parameter is passed two parameters: the animation Instance, and a loop count. My tests have verified that this isn't the case. (.love attached, the purple number is the animation, the white number is the loop count reported by the onLoop parameter).
I believe your problem lies within lines 230-232 of the v 2.1.0 code:
where self.timer never rises above self.totalDuration so loops never surpasses a value of 1.
2.) I tried to make a simple ping-pong function (animation would go 1 - 2 - 3 - 2 - 1 -2 - 3 ...) but discovered that there was no way to get the frame array from an animation once it's been created. Is there an easy way to achieve ping-ponging? (perhaps via the onLoop optional parameter?)
Otherwise, I'm enjoying using anim8. Thanks.
1.) The github wiki mentions that the "onLoop" parameter is passed two parameters: the animation Instance, and a loop count. My tests have verified that this isn't the case. (.love attached, the purple number is the animation, the white number is the loop count reported by the onLoop parameter).
I believe your problem lies within lines 230-232 of the v 2.1.0 code:
Code: Select all
local loops = math.floor(self.timer / self.totalDuration)
if loops ~= 0 then
self.timer = self.timer - self.totalDuration * loops
2.) I tried to make a simple ping-pong function (animation would go 1 - 2 - 3 - 2 - 1 -2 - 3 ...) but discovered that there was no way to get the frame array from an animation once it's been created. Is there an easy way to achieve ping-ponging? (perhaps via the onLoop optional parameter?)
Otherwise, I'm enjoying using anim8. Thanks.
- Attachments
-
- onLoopIsBroken.love
- (7.31 KiB) Downloaded 480 times
- 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
Hi CaptainMaelstrom,
1) onLoop works as intended - you just didn't understand how it works. Maybe I didn't explain it properly. Let me try again.
The logic is the following:
Every time you update the animation (with :update(dt)), an internal counter is increased to see if the animation has "reached its end".
In order to fix your demo, you just need to change this:
By this:
2) You can use onLoop to make "bouncing" animations, but it's easier to simply include the whole list of frames. When an animation does "ping pong" between frames 1,2,3 & 4, it also works in a loop; it just that the loop is a bit longer and looks like this: 1,2,3,4,3,2 (and then go back to the 1st, starting a new loop). Since you can use intervals, it's really short to write those down if the frames are in the right order on the grid. It'll look similar to
I hope this helps!
1) onLoop works as intended - you just didn't understand how it works. Maybe I didn't explain it properly. Let me try again.
The logic is the following:
Every time you update the animation (with :update(dt)), an internal counter is increased to see if the animation has "reached its end".
- If it hasn't, then onLoop it is not called.
- If it has, then onLoop is called, and you get how many loops have been completed on the last update - not from the beginning of the animation.
In order to fix your demo, you just need to change this:
Code: Select all
myOnLoop = function(animInst, loops)
count = loops
end
Code: Select all
myOnLoop = function(animInst, loops)
count = count + loops
end
Code: Select all
anim.newAnimation({'1-4',1,'3-2',1}, 0.1)
Last edited by kikito on Sat Sep 27, 2014 12:48 am, edited 1 time in total.
When I write def I mean function.
- CaptainMaelstrom
- Party member
- Posts: 163
- Joined: Sat Jan 05, 2013 10:38 pm
Re: [Library] anim8 - An animation library - v2.1.0 released
Ah, thanks kikito.
The loops counting explanation makes sense. I've never updated more than 17ms at a time, but I can see why I might want to at some point.
The ping-ponging solution works for me, too. I appreciate you clearing this up for me. Back to making games!
The loops counting explanation makes sense. I've never updated more than 17ms at a time, but I can see why I might want to at some point.
The ping-ponging solution works for me, too. I appreciate you clearing this up for me. Back to making games!
Re: [Library] anim8 - An animation library - v2.1.0 released
Hi, this is a really great library, it saved me a lot of headaches trying to figure out how to animate on my own.
I was wondering, could I get a detailed explanation of frames argument for newAnimation? It confuses me greatly, I have no idea how it works or what logical order it follows, I've only been able to make arbitrary guesses for what to pass it by browsing this thread.
For example, I have a sprite that needs to show the second frame, then the first, then the second, then the third, then loop. I've already got it doing that, so I don't need help, I just want to know how it works so I don't get stuck again. I would have assumed passing ('1-2, '1-1', '1-3', '1-2') would suffice, but that causes the animation to flip out and show a bunch of different frames that I don't want. I tried flipping the rows/columns around but it was the same mess. Then I find out the proper way to do it is (2, '1-1', 1, '1-1', 2, '1-1', 3, '1-1'). What's with the lone numbers in front of the row/column definitions, and why do the row/columns have to be 1-1 instead of the actual frame placements ('1-2', '1-3', etc.)? I can't see the order here, I have no idea how this argument system works. Thanks for your time. It's a wonderful and easy to use library, I just don't get this one part of it.
I was wondering, could I get a detailed explanation of frames argument for newAnimation? It confuses me greatly, I have no idea how it works or what logical order it follows, I've only been able to make arbitrary guesses for what to pass it by browsing this thread.
For example, I have a sprite that needs to show the second frame, then the first, then the second, then the third, then loop. I've already got it doing that, so I don't need help, I just want to know how it works so I don't get stuck again. I would have assumed passing ('1-2, '1-1', '1-3', '1-2') would suffice, but that causes the animation to flip out and show a bunch of different frames that I don't want. I tried flipping the rows/columns around but it was the same mess. Then I find out the proper way to do it is (2, '1-1', 1, '1-1', 2, '1-1', 3, '1-1'). What's with the lone numbers in front of the row/column definitions, and why do the row/columns have to be 1-1 instead of the actual frame placements ('1-2', '1-3', etc.)? I can't see the order here, I have no idea how this argument system works. Thanks for your time. It's a wonderful and easy to use library, I just don't get this one part of it.
- 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
In anim8 the frames are not "first", "second" or "third".konacake wrote:For example, I have a sprite that needs to show the second frame, then the first, then the second, then the third, then loop.
The frames of a grid are divided into rows and columns. In order to specify a frame you need two values (the row and the column). You can't say "first". You have to say "first row and first column". Or "first row, second column", or whatever is appropiate. You just can't use a single number. The "row" is called "x" and the "column" is called "y". They start at 1, and they go from left to right and from top to bottom respectively.
Think about the parameters you pass as groups of x and y parameters. For example:
Code: Select all
(1,1, 2,1, 3,1)
Notice that all the frames are on the same row on this case. Putting animations in this order is usual, so if you have an animation like this you can use a string for the row like this:
Code: Select all
('1-3', 1)
Let me know if this helps you.
When I write def I mean function.
Who is online
Users browsing this forum: No registered users and 3 guests