Skip to content

Instantly share code, notes, and snippets.

@metaphore
Created September 8, 2016 16:08
Show Gist options
  • Save metaphore/9f09238231d3494594b5900043e4f4ff to your computer and use it in GitHub Desktop.
Save metaphore/9f09238231d3494594b5900043e4f4ff to your computer and use it in GitHub Desktop.
Old corona image sheet format exporter for TexturePackerGUI
--
-- created with TexturePacker (http://www.codeandweb.com/texturepacker)
--
-- {{smartUpdateKey}}
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
local SheetInfo = {}
SheetInfo.sheet =
{
frames = {
{% for sprite in allSprites %}
{
-- {{sprite.trimmedName}}
x={{sprite.frameRect.x}},
y={{sprite.frameRect.y}},
width={{sprite.frameRect.width}},
height={{sprite.frameRect.height}},
{% if sprite.trimmed %}
sourceX = {{sprite.sourceRect.x}},
sourceY = {{sprite.sourceRect.y}},
sourceWidth = {{sprite.untrimmedSize.width}},
sourceHeight = {{sprite.untrimmedSize.height}}{% endif %}
},{% endfor %}
},
sheetContentWidth = {{texture.size.width}},
sheetContentHeight = {{texture.size.height}}
}
SheetInfo.frameIndex =
{
{% for sprite in allSprites %}
["{{sprite.trimmedName}}.png"] = {{ forloop.counter }},{% endfor %}
}
function SheetInfo:getOptions()
return self.sheet;
end
function SheetInfo:getFrameIndexByName(name)
return self.frameIndex[name];
end
return SheetInfo
<exporter version="1.0">
<!-- identifier of the exporter -->
<name>corona-imagesheet-old</name>
<!-- display name of the exporter for the combo box -->
<displayName>Corona(TM) SDK (old format image sheet)</displayName>
<!-- description of the exporter -->
<description>Exporter for Corona(TM) SDK using old image sheet format.</description>
<!-- exporter version -->
<version>1.0</version>
<!-- currently only one file allowed - more to come with update -->
<files>
<file>
<!-- name of this file variable -->
<name>lua</name>
<!-- human readable name (for GUI) -->
<displayName>Corona(TM) SDK lua file</displayName>
<!-- file extension for the file -->
<fileExtension>lua</fileExtension>
<!-- description what the file contains, used in tooltips in the GUI -->
<description>Lua file for Corona(TM) SDK</description>
<!-- name of the template file -->
<template>corona-imagesheet.lua</template>
</file>
</files>
<!-- target framework supports trimming -->
<supportsTrimming>true</supportsTrimming>
<!-- target framework supports rotated sprites -->
<supportsRotation>false</supportsRotation>
<!-- rotated sprites direction (cw/ccw) -->
<rotationDirection>cw</rotationDirection>
<!-- supports npot sizes -->
<supportsNPOT>true</supportsNPOT>
<!-- supports file name stripping (remove .png etc) -->
<supportsTrimSpriteNames>yes</supportsTrimSpriteNames>
<!-- supports texure subpath -->
<supportsTextureSubPath>yes</supportsTextureSubPath>
<!-- vector from center of untrimmed image to center of trimmed image must have integer coordinates -->
<ensureIntegerCenterOffset>yes</ensureIntegerCenterOffset>
</exporter>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment