TexMate- Atlas importer and animation library
Posted: Mon Sep 21, 2015 6:43 am
I made a neat little library.
https://github.com/Muzz/TexMate
It uses the corona TM SDK exporter from texturepacker. https://www.codeandweb.com/texturepacker
Or you can use shoebox which is free but i don't like as much. I have included a settings file for shoebox. http://renderhjs.net/shoebox/
This is my favorite workflow for making sprite animations in games. No needing to fuck around with hand made atlases or grids, just call the file name and it preserves the offset and pivot data.
Features i may add-
Hmm i tried making it class commons but it crashes with slither or 30 log instead of middleclass :/.
https://github.com/Muzz/TexMate
It uses the corona TM SDK exporter from texturepacker. https://www.codeandweb.com/texturepacker
Or you can use shoebox which is free but i don't like as much. I have included a settings file for shoebox. http://renderhjs.net/shoebox/
This is my favorite workflow for making sprite animations in games. No needing to fuck around with hand made atlases or grids, just call the file name and it preserves the offset and pivot data.
Code: Select all
--Class commons library
class = require("middleclass")
AtlasImporter = require("AtlasImporter")
TexMate = require("TexMate")
function love.load ()
--Load atlas you want to use
--myAtlas = AtlasImporter.loadAtlasShoeBox("ASSETS/sprites","ASSETS/sprites.png")
myAtlas = AtlasImporter.loadAtlasTexturePacker("ASSETS/spriteTP2","ASSETS/spriteTP.png")
-- use the exporter marked Corona TM SDK from texture packer.
-- If using shoebox, use the settings file provided
animlist = {}
animlist["Death"] = {
framerate = 14,
frames = {
"Death001",
"Death002",
"Death003",
}
}
animlist["Run"] = {
framerate = 14,
frames = {
"Run001",
"Run002",
"Run003",
}
}
--make the sprite , arguments: atlas, animlist, defaultanim, x, y, pivotx, pivoty, rotation
--Pivot x and y is an offset from the center of the image.
sprite = TexMate(myAtlas,animlist,"Death",nil,nil,0,-30)
sprite:changeAnim("Run")
end
function love.update(dt)
sprite:update(dt)
end
function love.draw()
sprite:draw()
end
Features i may add-
- a way to change transform and delay to individual frames. (not quite sure how i want to do this without bloating the input code)
- A function that generates the file names from a base name and a range.
- A callback for when a specific frame is hit
- looping
- end of animation callback
Hmm i tried making it class commons but it crashes with slither or 30 log instead of middleclass :/.