I want to make a project for school and asked myself: "Can I use GIFs in love2d?"
So yeah, is there any way you can do. I searched the entire web but found only one therad but the links with the solution weren't avaible anymore. So is there any possibility? pls help
GIFs in love?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: GIFs in love?
why do you need gifs in LÖVE? gifs are a rather terrible format and if you don't need to use them for some very specific reason why would you. LÖVE doesn't support them by default but you could theoretically write your own parser.GamerDMG wrote:I want to make a project for school and asked myself: "Can I use GIFs in love2d?"
So yeah, is there any way you can do. I searched the entire web but found only one therad but the links with the solution weren't avaible anymore. So is there any possibility? pls help
- Sheepolution
- Party member
- Posts: 264
- Joined: Mon Mar 04, 2013 9:31 am
- Location: The Netherlands
- Contact:
Re: GIFs in love?
Welcome!
As far as I know, you can't put gifs in LÖVE. Is it animated images that you want? You can use quads for that.
First you need to turn the gif into a spritesheet. In case you don't have tools for that, you can use http://gif2sprite.com/ (Put it on PNG instead of JPG).
Click on View Sprite, right-click, and download the sprite.
Now in game you load the image
Next we need to make quads. With quads we can draw parts of images.
Change FRAMES into the number of frames your animation has.
Now we need a timer
Change speed to make the animation go faster. Now we need to draw it
Tada.
Or, you know, use a library like anim8.
As far as I know, you can't put gifs in LÖVE. Is it animated images that you want? You can use quads for that.
First you need to turn the gif into a spritesheet. In case you don't have tools for that, you can use http://gif2sprite.com/ (Put it on PNG instead of JPG).
Click on View Sprite, right-click, and download the sprite.
Now in game you load the image
Code: Select all
function love.load()
image = love.graphics.newImage("spritesheet.png")
Code: Select all
quads = {}
local imgWidth, imgHeight = image:getWidth(), image:getHeight()
local spriteWidth = imgWidth / FRAMES
for i=0,FRAMES-1 do
table.insert(quads, love.graphics.newQuad(i * spriteWidth, 0, imgHeight, imgWidth, imgHeight)
end
Now we need a timer
Code: Select all
timer = 0
end
function love.update(dt)
timer = timer + dt * SPEED
end
Code: Select all
function love.draw()
love.graphics.draw(image, quads[(math.floor(timer) % FRAMES) + 1], 100, 100)
end
Or, you know, use a library like anim8.
-
- Citizen
- Posts: 87
- Joined: Tue Dec 30, 2014 6:07 pm
Re: GIFs in love?
If you want animation then you can use the video support Love provides with ogg files.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests