TexMate- Atlas importer and animation library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
Muzz
Citizen
Posts: 54
Joined: Sun Jun 28, 2015 1:24 pm

TexMate- Atlas importer and animation library

Post by Muzz »

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.

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
Edit:

Hmm i tried making it class commons but it crashes with slither or 30 log instead of middleclass :/.
AndreasLoew
Prole
Posts: 1
Joined: Mon Sep 21, 2015 6:18 pm

Re: TexMate- Atlas importer and animation library

Post by AndreasLoew »

Nice ;-) Thanks for sharing the lib.
Muzz
Citizen
Posts: 54
Joined: Sun Jun 28, 2015 1:24 pm

Re: TexMate- Atlas importer and animation library

Post by Muzz »

Haha thanks Andreas, texture packer has proved to be a handy little bit of software. Don't suppose this means i can get a free upgrade of texture packer ;)?
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests