Page 1 of 1

iffy: A spritesheet helper library

Posted: Tue Dec 03, 2019 8:00 am
by YoungNeer
Have you ever used Kenney's assets? Then you may know that all of Kenney's assets are "game-ready". Meaning you don't have to tweak anything or do some extra work to load those assets.
Every spritesheet of Kenney - unless it's a tileset or has animations in it - has an XML file by the same name.

Let me give you context. Here's a spritesheet made by Kenney (on left is the image 'diceRed.png' and on right is the metafile diceRed.xml)
spritesheetXML.png
spritesheetXML.png (32.36 KiB) Viewed 973 times
How would you go about this? Well with iffy you'd do something like this:-

Code: Select all

iffy=require 'iffy'

iffy.newSpriteSheet("diceRed.png")

function love.draw()
	iffy.drawSprite('diceRed6.png')
end
and that'd draw the 6-faced die on the screen at (0,0)!

Github Link

Re: iffy: A spritesheet helper library

Posted: Tue Dec 03, 2019 5:14 pm
by ingsoc451
Here something I used while working with Kenney's sprite sheets. It converts the specific xml format to a lua table

Re: iffy: A spritesheet helper library

Posted: Wed Dec 04, 2019 4:27 am
by YoungNeer
ingsoc451 wrote:
Tue Dec 03, 2019 5:14 pm
Here something I used while working with Kenney's sprite sheets. It converts the specific xml format to a lua table
Iffy too converts that specific xml format to lua table - it returns all the quads in a neat hashtable format! But you don't need to store that to any table since iffy stores a cache and you can draw a sprite using iffy.drawSprite or be more specific with iffy.draw

Re: iffy: A spritesheet helper library

Posted: Wed Dec 04, 2019 9:42 am
by ingsoc451
You only need to convert it one time. It looks like it converts it everytime

Re: iffy: A spritesheet helper library

Posted: Wed Dec 04, 2019 12:07 pm
by YoungNeer
ingsoc451 wrote:
Wed Dec 04, 2019 9:42 am
You only need to convert it one time. It looks like it converts it everytime
It doesn't!! It may look like it cause "it is looking for cache" when there is no cache to speeden up the process of acessing things - especially for drawSprite function!