Hey there I am Jon, the creator of Objecty. Thanks for posting this. I am currently hard at work to try and get a demo pushed out there for people to try.
We really could do with all the support you guys can give and if you have any questions then please ask me via email, twitter, via kickstarter or on here.
To give you an idea of how the exporters can work, I recently experiemented with an MMF2 exporter. You can see a screenshot here.
This consists of only 2 files.
XML file to describe the exporter
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<exporter version="1.0">
<details>
<icon>icons/mmf2.png</icon>
<formats>
<format class="image">png</format>
</formats>
<title>
<language name="english">MMF2</language>
</title>
<description><language name="english">Export the sprite sheet as a png that can be imported by mmf2 using the box mode import.</language></description>
</details>
<scripts>
<script>lua/mmf2.lua</script>
</scripts>
<settings>
<setting id="hotspot" class="bool" value="1">
<title><language name="english">Export Hotspot</language></title>
</setting>
<setting id="action_point" class="node_reference" value="0">
<configurations>
<configuration id="query">node_id(${node.unique_id})/node_class(spriteFrame)/node_id(\${node.atlas_item})/node_class(hotspot)/filter_unique_attribute(id)</configuration>
<configuration id="style">list</configuration>
<configuration id="preview">0</configuration>
<configuration id="can_edit">1</configuration>
<configuration id="can_reset">1</configuration>
</configurations>
<title><language name="english">Export Action Point</language></title>
</setting>
<setting id="transparent_color" class="color" value="255,0,255">
<title><language name="english">Transparent Color</language></title>
</setting>
</settings>
</exporter>
LUA script to perform the export operation
Code: Select all
function export(animation)
-- get some settings
transparentR,transparentG,transparentB = Setting("transparent_color")
hotspot = Setting("hotspot")
actionPoint = Setting("action_point")
-- get the frames from the animation
frames = animation:GetChildrenWithClass("spriteFrame")
framesTotal = #(frames)
-- first get some layout details for frames
frameWidth,frameHeight,frameOffsetX,frameOffsetY = animation:GetDimensions()
-- figure out the size of the output image
imageWidth = ((frameWidth+3) * framesTotal)+1
imageHeight = frameHeight+4
-- create output image
image = CreateImage(imageWidth,imageHeight)
-- get colors for box stuff
if transparentR == 255 and transparentG == 255 and transparentB == 255 then
borderR = 254
borderG = 254
borderB = 254
else
borderR = 255
borderG = 255
borderB = 255
end
if transparentR == 200 and transparentG == 200 and transparentB == 200 then
pointR = 199
pointG = 199
pointB = 199
else
pointR = 200
pointG = 200
pointB = 200
end
-- render the frames onto the output image
renderX = 0
renderY = 0
for index,frame in ipairs(frames) do
-- get frame details
frameCenterX,frameCenterY = frame:GetCenter()
-- draw transparent
image:Rect(renderX,renderY,frameWidth+4,frameHeight+4,false,transparentR,transparentG,transparentB,255,false)
-- draw the frame
image:Paste(frame:GetImage(),renderX+2+frameOffsetX-frameCenterX,renderY+2+frameOffsetY-frameCenterY,255,false)
-- draw the border
image:Rect(renderX+1,renderY+1,frameWidth+2,frameHeight+2,false,borderR,borderG,borderB,255,false)
-- draw the hotspot
if hotspot then
hotspotX = (frameOffsetX-frameCenterX) + frameCenterX
hotspotY = (frameOffsetY-frameCenterY) + frameCenterY
DebugLog(hotspotX.."x"..hotspotY)
if hotspotX >= 0 and hotspotX < frameWidth and hotspotY >= 0 and hotspotY < frameHeight then
image:Plot(renderX+1+hotspotX,renderY+1,pointR,pointG,pointB,255,false)
image:Plot(renderX+1,renderY+1+hotspotY,pointR,pointG,pointB,255,false)
end
end
-- draw the action point
if actionPoint then
actionPointX = 3
actionPointY = 10
if actionPointX >= 0 and actionPointX < frameWidth and actionPointY >= 0 and actionPointY < frameHeight then
image:Plot(renderX+1+actionPointX,renderY+2+frameHeight,pointR,pointG,pointB,255,false)
image:Plot(renderX+2+frameWidth,renderY+1+actionPointY,pointR,pointG,pointB,255,false)
end
end
-- move the render offset
renderX = renderX + frameWidth + 3
end
-- save the image
image:Save("mmf2_output2.png")
image:Close()
end
From this particular plugin the output would be:
This cane be imported directly into mmf2. This is still in development and I definitely want to try and support many frameworks and languages, LOVE included.
thanks
Jon