Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.
<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
        <dict>
            <key>frames</key>
            <dict>
                <key>frame1.png</key>
                <dict>
                    <key>frame</key>
                    <string>{{0,0},{96,288}}</string>
                    <key>offset</key>
                    <string>{3,-6}</string>
                    <key>rotated</key>
                    <false/>
                    <key>sourceColorRect</key>
                    <string>{{80,12},{96,288}}</string>
                    <key>sourceSize</key>
                    <string>{250,300}</string>
                </dict>
                <key>frame2.png</key>
                <dict>
                    <key>frame</key>
                    <string>{{96,0},{96,288}}</string>
                    <key>offset</key>
                    <string>{3,-6}</string>
                    <key>rotated</key>
                    <false/>
                    <key>sourceColorRect</key>
                    <string>{{80,12},{96,288}}</string>
                    <key>sourceSize</key>
                    <string>{250,300}</string>
                </dict>

Above there is a part of a plist output in cocos2d format. each frame has own node, I do not know what is offset, sourceColorRect is. the first string node is the Rectangle of the current frame on sprite, but what are the "offset", "sourceColorRect" and "sourceSize"

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Here's an explanation of the keys.

frame

The sprite location within the sprite-sheet as position and size values.

offset

Most of the current texture packing tools remove transparent areas of the image before they pack it. Imagine you got a sprite with the size of 100x100, but on the left and right there are 4 columns of totally transparent pixels. The packing tool will remove these to save space, but store offset and sourceSize, so that your sprite will be 100x100 pixels in your game. Note that the offset is always relative to the center of the sprite (comparing the center of the cropped and the center of the original sprite).

rotated

Whether or not the sprite has been rotated within the sprite-sheet (if this is true, the sprite is rotated 90 degrees clockwise).

sourceColorRect

The rectangle with actual color information inside your source sprite. If you take the 100x100 image described above (with 4px transparent pixels on the left and on the right), the sourceColorRect will be {{4,0},{92,100}}

sourceSize

This is the size of the original sprite (beware that some texture-packers can add padding to this if you chose to).


I'm making this CW, so anybody can add corrections.

share|improve this answer
    
For future reference, making answers CW isn't really necessary anymore. Anybody can make suggested edits that go in a queue that high reputation users can then decide to approve: blog.stackoverflow.com/2011/02/suggested-edits-and-edit-review –  Tetrad Oct 20 '11 at 23:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.