TexturePacker + LÖVE + SpriteBatch

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
abigpotostew
Prole
Posts: 2
Joined: Tue Jan 14, 2014 4:31 am

TexturePacker + LÖVE + SpriteBatch

Post 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!
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TexturePacker + LÖVE + SpriteBatch

Post 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.
User avatar
Madrayken
Party member
Posts: 126
Joined: Sun May 04, 2014 4:21 pm
Location: Oakland CA
Contact:

Re: TexturePacker + LÖVE + SpriteBatch

Post 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.
Discord: https://discord.gg/tYfHgXc
Bandcamp: https://madrayken.bandcamp.com/
Twitter: @Fluttermind
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest