Created
December 13, 2012 05:02
-
-
Save ripter/4274146 to your computer and use it in GitHub Desktop.
Zwoptex template for Löve2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SpriteSheet | |
-- Handles custom Zwoptex template: https://gist.github.com/4274146 | |
module('SpriteSheet', package.seeall) | |
local SpriteSheet = {} | |
-- Loads and creates the sprite sheet from sheetName | |
function SpriteSheet:new(sheetName) | |
local ss = require(sheetName) | |
setmetatable(ss, { __index = self }) | |
return ss | |
end | |
function SpriteSheet:draw(name, x, y, r, sx, sy, ox, oy, kx, ky ) | |
love.graphics.drawq( self.image, self.frames[name].quad, x, y, r, sx, sy, ox, oy, kx, ky ) | |
end | |
return SpriteSheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module('{{ metadata.target.textureFileName }}', package.seeall) | |
-- This file is for use with Löve2d and was generated by Zwoptex (http://zwoptexapp.com/) | |
-- | |
-- This is an extremely simple conversion. | |
-- Format written by Chris Richards. | |
local fileName = '{{ metadata.target.textureFileName}}{{ metadata.target.textureFileExtension }}' | |
local sheet = { | |
fileName = fileName | |
, image = love.graphics.newImage(fileName) | |
, frames = { | |
{% for sprite in sprites %} | |
{{ sprite.nameWithoutExtension }} = { | |
quad = love.graphics.newQuad({{ sprite.textureRectX }}, {{ sprite.textureRectY }}, {{ sprite.textureRectWidth }}, {{ sprite.textureRectHeight }}, {{ metadata.sizeWidth }}, {{ metadata.sizeHeight }}) | |
, name = "{{ sprite.nameWithoutExtension }}" | |
, rect = { x = {{ sprite.textureRectX }}, y = {{ sprite.textureRectY }}, width = {{ sprite.textureRectWidth }}, height = {{ sprite.textureRectHeight }} } | |
}, | |
{% /for %} | |
} | |
} | |
return sheet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment