[SOLVED] Anim8 - Create animation for each new object

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.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

[SOLVED] Anim8 - Create animation for each new object

Post by var77 »

Hi everyone, it's been a long time since I ain't post any issue :nyu: .

So I use anim8 to make some animation with classic:

Code: Select all

local g = anim8.newGrid (...)
ani_1 = anim8.newAnimation(...)
ani_2 = anim8.newAnimation(...)
ani_list = [ani_1,ani_2]

function update(t)
	ani_list:update(t)
end

function draw()
	ani_1:draw
	ani_2:draw
end
It works perfectly but here is the deal, if I want to use "ani_1" for several object they seems that they all got the same sequence frame.
How could I generate animation individually for each of my object and start when they're create ?

Cause try several method like clone() (don't guess this is the way to use this function) but ain't works:

Code: Select all

ani_1_ = anim8.newAnimation(...)
ani_1 = ani_1:clone()

obj_list = {{1,anim=ani_1},{2,anim=ani_1}}
--object are not create at the same time in the list

for i, o in ipairs(obj_list) do
	o.anim:draw(...)
end
if anyone got an idea :)
Regards
Last edited by var77 on Wed Jun 30, 2021 5:04 pm, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Anim8 - Create animation for each new object

Post by grump »

var77 wrote: Mon Jun 28, 2021 10:20 pm

Code: Select all

ani_1_ = anim8.newAnimation(...)
ani_1 = ani_1:clone()
You probably want this to say

Code: Select all

ani_1 = anim8.newAnimation(...)
ani_2 = ani_1:clone()
for hopefully obvious reasons.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Anim8 - Create animation for each new object

Post by var77 »

Thanks for your fast reply @grump but that's not what i'm looking for unfortunatly.
To be more helpfull I just add a zip of my issue (line 175).
test.zip
(5.99 MiB) Downloaded 361 times
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: Anim8 - Create animation for each new object

Post by monolifed »

There is already a library called anim8 https://github.com/kikito/anim8
Last edited by monolifed on Tue Jun 29, 2021 2:23 pm, edited 1 time in total.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Anim8 - Create animation for each new object

Post by var77 »

monolifed wrote: Tue Jun 29, 2021 11:58 am There is already a library called anim8 https://github.com/kikito/anim8
Actually that's what I use :nyu:
var77 wrote: Mon Jun 28, 2021 10:20 pm So I use anim8 to make some animation
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: Anim8 - Create animation for each new object

Post by monolifed »

Do you want something like this?
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Anim8 - Create animation for each new object

Post by var77 »

Thanks a lot monolifed that's exaclty what i was looking for. Just need to studdy your main.lua to apply it to my works.
I may gonna have few questions soon :nyu: .
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: [SOLVED] Anim8 - Create animation for each new object

Post by var77 »

So after few days investigating your main.lua monolifed,that was very helpfull (and informativ), I found most of what I was searching for the first part. I just stuck a bit with other stuff (maybe 'cause I aint know how to handle it with Anim8).

I would like to reverse animation (rewind the spinning) and roll again with new list of animation.

I thought that I could duplicate all function but get stuck with "onLoop" and list of animation.

Basicly what I try to get is:
Step 1 [ok] - spinning (random list)
Step 2 [ok] - random select 1 object (got it)
Step 3 [ - ] - rewind spinning(only not selected object)
Step 4 [ - ] - spinning_result

Code: Select all

-- on load
	spinning = {
		anim8.newAnimation(g32('1-8',1), 0.1, onLoop),
		anim8.newAnimation(g32('1-8',2), 0.1, onLoop),
		anim8.newAnimation(g32('1-8',3), 0.1, onLoop)		
	}
	-- if I could rewind animation with function I guess it might be easier than this
	rewind_spinning = {
		anim8.newAnimation(g32('8-1',1), 0.1, onLoop),
		anim8.newAnimation(g32('8-1',2), 0.1, onLoop),
		anim8.newAnimation(g32('8-1',3), 0.1, onLoop)
	}
	
	spinning_result = {		
		anim8.newAnimation(g32('1-8',4), 0.1, onLoop)
		anim8.newAnimation(g32('1-8',5), 0.1, onLoop)
	}
--
If you got any idea :nyu:
User avatar
idbrii
Prole
Posts: 34
Joined: Sat Jun 12, 2021 5:07 am

Re: [SOLVED] Anim8 - Create animation for each new object

Post by idbrii »

The README says:

> However that way you will get a submarine which "emerges", then "suddenly disappears", and emerges again. To make it look more natural, you must add some animation frames "backwards", to give the illusion of "submersion". Here's the complete list:

> local frames = gs('1-7',1, '6-2',1)

So you can put lots of animation frames together. Would something like this work for you:

anim8.newAnimation(g32('1-8',1, '8-1',2, '1-8',4), 0.1, onLoop),

I don't really understand what you're trying to do, but I assume you want a spin animation, then a rewind animation, then another spin animation?


> -- if I could rewind animation with function I guess it might be easier than this

Isn't that what animation:gotoFrame(frame) does?

When experimenting with this, I'd recommend making an unmoving object playing your animation and use love.keypressed to cycle between different ways of calling newAnimation (or use hotloading if you've got that setup).
User avatar
togFox
Party member
Posts: 779
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: [SOLVED] Anim8 - Create animation for each new object

Post by togFox »

If rewinding I would just add those frames in reverse order so it spins forward then backwards then loops again or starts a different animation. Far easier.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 86 guests