iOS_31_cocos2d_纹理打包(TexturePacker)
举例说明,有一张260x260像素的32位色图,
它在内存中大概占270KB(260 x 260 x 32 / 8 = 270400B),
但受纹理尺寸的限制,纹理的尺寸必须是2的n次幂,
系统将自动生成一张最接近原图尺寸的(只会比原图尺寸大)、宽高都为2的n次幂的纹理,
因此,系统将会生成一张512x512像素的纹理,
并且,最终会占用1MB的内存(512 x 512 x 32 / 8 = 1048576B),
可以看出,实际占用的内存竟然是原图所需内存的4倍。
解决办法就是将这张260x260像素的图像改为256x256像素,系统也将生成256x256像素的纹理。
<?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>1.png</key> <dict> <key>frame</key> <string>{{2,416},{92,107}}</string> <key>offset</key> <string>{-29,-26}</string> <key>rotated</key> <true/> <key>sourceColorRect</key> <string>{{91,56},{92,107}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>10.png</key> <dict> <key>frame</key> <string>{{111,414},{184,81}}</string> <key>offset</key> <string>{-3,-29}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{71,72},{184,81}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>2.png</key> <dict> <key>frame</key> <string>{{2,224},{190,81}}</string> <key>offset</key> <string>{-71,-29}</string> <key>rotated</key> <true/> <key>sourceColorRect</key> <string>{{0,72},{190,81}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>3.png</key> <dict> <key>frame</key> <string>{{297,337},{136,127}}</string> <key>offset</key> <string>{-46,-6}</string> <key>rotated</key> <true/> <key>sourceColorRect</key> <string>{{52,26},{136,127}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>4.png</key> <dict> <key>frame</key> <string>{{297,182},{158,153}}</string> <key>offset</key> <string>{-59,7}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{28,0},{158,153}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>5.png</key> <dict> <key>frame</key> <string>{{85,224},{188,149}}</string> <key>offset</key> <string>{-12,5}</string> <key>rotated</key> <true/> <key>sourceColorRect</key> <string>{{60,4},{188,149}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>6.png</key> <dict> <key>frame</key> <string>{{2,2},{242,143}}</string> <key>offset</key> <string>{45,2}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{90,10},{242,143}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>7.png</key> <dict> <key>frame</key> <string>{{246,2},{242,119}}</string> <key>offset</key> <string>{45,-10}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{90,34},{242,119}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>8.png</key> <dict> <key>frame</key> <string>{{246,123},{232,57}}</string> <key>offset</key> <string>{40,-41}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{90,96},{232,57}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> <key>9.png</key> <dict> <key>frame</key> <string>{{2,147},{198,75}}</string> <key>offset</key> <string>{24,-32}</string> <key>rotated</key> <false/> <key>sourceColorRect</key> <string>{{91,78},{198,75}}</string> <key>sourceSize</key> <string>{332,167}</string> </dict> </dict> <key>metadata</key> <dict> <key>format</key> <integer>2</integer> <key>realTextureFileName</key> <string>zhaoyun.png</string> <key>size</key> <string>{512,512}</string> <key>smartupdate</key> <string>$TexturePacker:SmartUpdate:aae1cbd56ecaac00aa0364cad5d7b3d2:1/1$</string> <key>textureFileName</key> <string>zhaoyun.png</string> </dict> </dict> </plist>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。