Page 1 of 1

TexturePacker + LÖVE + SpriteBatch

Posted: Tue Jan 14, 2014 5:36 am
by abigpotostew
I made a custom exporter for TexturePacker so you can use LÖVE's SpriteBatch more easily with assorted images. No more manually creating Quads for each image in a packed texture!! Hooray. Now you can throw all your images into TexturePacker which then exports a texture atlas and a lua file which loads all your quads with just one require() call.

Sample Usage:

Code: Select all

function love.load()
    myAtlas = require("mytextureatlas")
    batch = love.graphics.newSpriteBatch( myAtlas.texture, 100, "stream" )
end

function love.draw()
    batch:clear()
    batch:bind()
        batch:add( myAtlas.quads['mySpriteName'], love.mouse.getX(), love.mouse.getY() )
    batch:unbind()
    love.graphics.draw(batch)
end
Download the files here: https://github.com/abigpotostew/love-texturepacker

Feel free to use this however you want. Enjoy!

Re: TexturePacker + LÖVE + SpriteBatch

Posted: Tue Jan 14, 2014 8:14 am
by SiENcE
Nice one! I have my own...but using Texturepacker seems to be nicer.

I'm going to test it and give you feedback.

Re: TexturePacker + LÖVE + SpriteBatch

Posted: Tue Mar 15, 2016 6:20 pm
by Madrayken
At the risk of necro-threading, it would be amazing if there were a meshsprite variant, and exporter for TP to minimise overdraw. It might not be such a big deal on PC/Mac, but for mobile it's so useful.