The meaning of plist and JSON files describing the sprite frame picture in Cocos2d-x

Source: Internet
Author: User

Recently in the study of cocos, the Internet industry, hand tourism recent performance is a very fire, coupled with its own interest in the game, so they have to meddle in the game engine ~

This time the nonsense is so short, because the record of the things itself is very few.

In cocos, adding a cache for Sprite frames can be done in the following way

Cc.spriteFrameCache.addSpriteFrames (URL, texture)

Where the first parameter is a plist or JSON file path, the second parameter is a texture picture object, generally do not pass on the

Once you have added the sprite frame cache, we can create the wizard by following the methods below

New CC. Sprite ("#帧名")

The frame name is configured in the plist or JSON file, of course, the plist or JSON file describes not only the frame name, but also each frame corresponds to which part of the picture

The following is one of the simplest plist file instances

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" ><plist Version= "1.0" ><dict> <key>frames</key> <dict> <key>icon001</key> &LT;DICT&G      T <key>frame</key> <string>{{0,0},{240,240}}</string> <key>offset</key> & lt;string>{0,0}</string> <key>rotated</key> <false/> <key>sourcecolorrect& lt;/key> <string>{{0,0},{240,240}}</string> <key>sourceSize</key> <string> {240,240}</string> </dict> </dict> <key>metadata</key> <dict> <key>form at</key> <integer>2</integer> <key>realTextureFileName</key> <string>b01.png& lt;/string> <key>size</key> <string>{240,240}</string> <key>textureFileName</key> <string>b01.png</string> </dict></dict></plist> 

One more example of JSON

{    "Frames" : {        "Icon001" : {            "Frame": "{{2,0},{640,305}}",            "Offset": "{0,0}",            "Rotated":false,            "Sourcecolorrect": "{{0,0},{640,305}}",            "Sourcesize": "{640,305}"        },        "Icon002" : {            "Frame": "{{2,625},{320,182}}",            "Offset": "{0,0}",            "Rotated":false,            "Sourcecolorrect": "{{0,0},{320,182}}",            "Sourcesize": "{320,182}"        }    },    "Metadata" : {        "Format": 2,        "Realtexturefilename": "Ui_new_icon_png.png",        "Size": "{1024, 1024}",        "Texturefilename": "Ui_new_icon_png.png"    }}

The meaning of plist and JSON files describing the sprite frame picture in Cocos2d-x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.