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> <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