Hi all,
I just started using Love, and am wondering how to make an animation play after a previous animation has finished playing. I have been searching for some type of wait or sleep command, but had no luck.
Any help is appreciated!
Animation order
- EmmanuelOga
- Citizen
- Posts: 56
- Joined: Thu Apr 22, 2010 9:42 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Animation order
you'll need to have a count of the elapsed time. In its rawest form:
You can cleanup a lot that code by using some sort of timer, like the one included in HUMP, which works kind of like javascript's setTimeout and setInterval.
https://github.com/vrld/hump/blob/master/timer.lua
EDIT: with hump's timer it would be something like: (docs at http://vrld.github.com/hump/#timer)
If you need full-blown tweened animations, check https://github.com/EmmanuelOga/tweener.
Code: Select all
local phase = 1
function love.draw()
if phase == 1 then
-- do stuff
elseif phase == 2 then
-- do stuff
-- etc...
end
end
local elapsed = 0
local PHASE1_TIME = 2 -- seconds
function love.update(dt)
elapsed = elapsed + dt
if elapsed > PHASE1_TIME then phase = 2 end
end
https://github.com/vrld/hump/blob/master/timer.lua
EDIT: with hump's timer it would be something like: (docs at http://vrld.github.com/hump/#timer)
Code: Select all
Timer = require "hump.timer"
local phase = 1
Timer.add(5, function() -- change to phase 2 in 5 seconds
phase = 2
Timer.add(10, function() --after changing to phase 2, switch to phase 3 in 10 seconds.
phase = 3
end)
end)
function love.draw()
if phase == 1 then
-- do stuff
elseif phase == 2 then
-- do stuff
-- etc...
end
end
function love.update(dt)
Timer.update(dt)
end
--------------------------------------------------------------------------------------------------------
http://EmmanuelOga.com
http://EmmanuelOga.com
Re: Animation order
lQuery framework isn't complete, but consists powerful animation queues like jQuery in JavaScript. Maybe this is frameork you looking for:)
http://love2d.org/forums/viewtopic.php?f=5&t=2570
Queued animations:
http://love2d.org/forums/viewtopic.php? ... 341#p27341
http://love2d.org/forums/viewtopic.php?f=5&t=2570
Queued animations:
http://love2d.org/forums/viewtopic.php? ... 341#p27341
Re: Animation order
Thanks for the info!
I am having some trouble getting HUMPs timer to work though, I am getting an error with "Timer = require "hump.timer", module not found.
I have timer.lua in the root of the project folder, and it is required in main.lua. Is there anything else I must do to use that module?
I am having some trouble getting HUMPs timer to work though, I am getting an error with "Timer = require "hump.timer", module not found.
I have timer.lua in the root of the project folder, and it is required in main.lua. Is there anything else I must do to use that module?
- EmmanuelOga
- Citizen
- Posts: 56
- Joined: Thu Apr 22, 2010 9:42 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Animation order
Try putting it on hump/timer.lua.spidarmen wrote:Thanks for the info!
I am having some trouble getting HUMPs timer to work though, I am getting an error with "Timer = require "hump.timer", module not found.
I have timer.lua in the root of the project folder, and it is required in main.lua. Is there anything else I must do to use that module?
--------------------------------------------------------------------------------------------------------
http://EmmanuelOga.com
http://EmmanuelOga.com
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Animation order
You're requiring it wrong. You need to put it into a folder called hump. This is because when Lua sees a dot in a require path, it changes it to a forward slash (/). Therefore it's looking at: hump/timer.lua.spidarmen wrote:Thanks for the info!
I am having some trouble getting HUMPs timer to work though, I am getting an error with "Timer = require "hump.timer", module not found.
I have timer.lua in the root of the project folder, and it is required in main.lua. Is there anything else I must do to use that module?
EDIT: Ninja'd. Lol.
Re: Animation order
Ah, that would be the problem.
Thanks for the speedy reply!
Thanks for the speedy reply!
Who is online
Users browsing this forum: No registered users and 5 guests