Search code examples
iosobjective-cplistsprite-sheet

What are "offset" and "sourceColorRect" keys texturepacker pList schema?


I'm writing a .NET service to provide data that matches the texturepacker schema to make it easy for the iOS devs to use my generated spritesheets. Here's a basic node (and I've yet to find documentation):

       <dict>
            <key>frame</key>
            <string>{{449,767},{139,117}}</string>
            <key>offset</key>
            <string>{0,0}</string>
            <key>rotated</key>
            <true/>
            <key>sourceColorRect</key>
            <string>{{0,0},{139,117}}</string>
            <key>sourceSize</key>
            <string>{139,117}</string>
        </dict>

Besides the obvious redundancies in the schema, there's "frame" is this the destination rectangle?

What is sourceColorRect? If that's just source, why not call it that and get rid of sourceSize, as that's a redundancy?

Also, what is offset? Is that like a registration point thing? Can I ignore that if we don't need origin coordinate info?

Seems like ideally this list would look like

    - frame (but is this really the destRect?)
    - sourceRect
    - destRect
    - rotated
    - offset

Maybe it would be easier to just give my own pList with simplified data and just the barebones what the iOS dev would need to determine image_name as keys and forget about what a "frame" is.


Solution

  • First of all: The format was not invented by me - it's what cocos2d can read. I know that there are some redundancies - but that can't be changed without changing cocos2d.

    frame: {{x,y},{width,height}} That's the position of the image inside the sprite sheet.

    offset: If you have trimmed sprites, that's the offset between the original sprite and the trimmed one. In your case you could easily ignore it

    rotated: If the sprite was rotated or not - guess you can omit that too

    sourceColorRect: The part of the original sprite that was taken. only important if trimmed

    sourceSize: The original size of the untrimmed sprite