ATLAS是一種將多個PNG文件合并到一個大紋理集中的技術。JSON文件用于描述紋理集中每個圖片在哪里、大小、位置和旋轉因素等等。PNG文件則是紋理集的實際圖像。這種技術常用于游戲開發中,可以減少內存占用,提高游戲的啟動速度。
{ "frames": { "image0.png": { "frame": {"x":0, "y":0, "w":139, "h":135}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":139,"h":135}, "sourceSize": {"w":139,"h":135} }, "image1.png": { "frame": {"x":0, "y":135, "w":40, "h":38}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":0,"y":0,"w":40,"h":38}, "sourceSize": {"w":40,"h":38} }, "image2.png": { "frame": {"x":139, "y":0, "w":114, "h":142}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":114,"h":142}, "sourceSize": {"w":114,"h":142} }, }, "meta": { "app": "myAppName", "version": "1.0", "image": "myAtlas.png", "format": "RGBA8888", "size": {"w":253,"h":177}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:36d3d2e2c3aeeabf3806ab8782ee91d3:fdfa04c4bc3c21cfb727d9a7af3ce097:5f61a401e28aa61654b5a82b82a1cf81$" } }
上面的JSON文件是一個ATLAS格式的描述文件。里面包含了幾個圖片的描述信息,包括位置、大小、旋轉等。如果要使用這個ATLAS,我們需要使用ATLAS的解析庫,將指定的JSON文件和PNG文件一起加載,解析成一個個獨立的Sprite對象。這個過程通常由游戲引擎的資源管理器完成。