Atlas assets
In a game, using an Atlas composed of multiple pictures as art assets has the following advantages:
- The blank area around each picture will be removed when synthesizing the Atlas, plus various optimization algorithms can be implemented as a whole. After synthesizing the Atlas, the game package and memory consumption can be greatly reduced.
For a more comprehensive explanation, watch a teaching video: from CodeAndWeb.
Next, use special software to generate the Atlas. Examples:
When using these software packages to generate an Atlas, please select a file in Cocos2d-x format. The resulting Atlas files are a and with the same name. Example: and .
When using TexturePacker software, please note that use v4.x only, v3.x and below is not supported.
Drag the .plist and the .png files shown above into the Assets panel at the same time. It is possible to generate Atlas assets that can be used in the editor and scripts.
In the , the relationship between Texture and SpriteFrame was introduced. After importing the Atlas, we can see that the Atlas is of type Atlas and can be expanded by clicking the triangle icon on the left. After expanding, we can see that the Atlas contains many sub-assets of type SpriteFrame. Assets are pictures that can be used and referenced individually.
The use of the Sprite Frame is the same as that described in the image asset. Please refer to the related documents.