Is there any way to program a .gif or .avi to play in Love?
Also, on a side note, anyway to compress a .gif animation so I can upload it here?
Playing animations
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Playing animations
"your actions cause me to infer your ego is the size of three houses" -finley
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Playing animations
Love doesn't support either of those. You could export the frames as .jpegs and flip through them if it's a short animation, though (I assume it is since you're talking about .gif).
As for making animated .gifs, I normally use VirtualDub. It's a light video processing tool, and can export to .gif.
As for making animated .gifs, I normally use VirtualDub. It's a light video processing tool, and can export to .gif.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
-
- Prole
- Posts: 18
- Joined: Sun Oct 09, 2011 1:12 am
Re: Playing animations
You could use each frame of the .gif as the animation like this:
My apologies for icky or invalid code. Still kinda new at this. There's also probably a better way to reset TimeInSeconds.
Code: Select all
function love.load()
frame1 = love.graphics.newImage("x.png")
frame2 = love.graphics.newImage("y.png")
end
function love.update(TimeInSeconds)
if TimeInSeconds == 1 then
love.graphics.draw(frame1, xpos, ypos)
elseif TimeInSeconds == 2 then
love.graphics.draw(frame2, xpos, ypos)
TimeInSeconds = 0
end
end
Re: Playing animations
the value passed to love.update is actually the time since the last frame: so while it is in seconds, it is usually very low (0.016 for 60fps)
so if, for example, you wanted something to occur roughly every second, you would do something like:
EDIT:
Also note that the screen is cleared between love.update and love.draw, so any draws inside love.update wont show.
so if, for example, you wanted something to occur roughly every second, you would do something like:
Code: Select all
local timer = 0
local interval = 1
function love.update(dt)
timer = timer + dt
if timer > 1 then
timer = timer -interval
--do stuff
end
end
Also note that the screen is cleared between love.update and love.draw, so any draws inside love.update wont show.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Playing animations
What's also often done is placing all the frames of an animation on a single image, and using a quad that changes its viewport to animate.
Help us help you: attach a .love.
Re: Playing animations
*.avi will not work without video support, so no way.LuaWeaver wrote:Is there any way to program a .gif or .avi to play in Love?
*.gif animation will not work directly, you will need to convert it to the series of frames. Beware, optimized animated gif is not just a sequence of frames - it can depend on the previous frame's content. Check this out for decompositing the animation:
http://www.imagemagick.org/Usage/anim_basics/
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Playing animations
Because OP asked about *.avi movies or *.gif animations, none of which are directly supported by AnAL?tentus wrote:How has no one mentioned AnAL yet?
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Playing animations
But AnAL does do the next best thing. Why force a confused newcomer to write their own animation system when we already have one that works?miko wrote:Because OP asked about *.avi movies or *.gif animations, none of which are directly supported by AnAL?tentus wrote:How has no one mentioned AnAL yet?
Kurosuke needs beta testers
Re: Playing animations
Thanks guys.
"your actions cause me to infer your ego is the size of three houses" -finley
Who is online
Users browsing this forum: Google [Bot] and 2 guests