0

我一直在搜索 cocos2d 论坛,但我不明白人们正在使用的一些概念。在我的游戏中,我必须加载超过 100 张图像作为主菜单的动画,但我遇到的问题是这些图像需要大约 3 到 5 秒才能加载,然后我的游戏就会启动。加载图像后动画运行良好,但问题在于加载。我会使用精灵表,但图像太大,所以我必须单独加载它们。那么我应该制作一个加载屏幕来首先加载所有这些图像,如果是这样,最好的方法是如何实现呢?这是我第一次尝试做这样的事情。

4

2 回答 2

1

@Stephen : Two ways to do this. With TexturePacker you can create a .tps file, one for each source image, then under File->Export Image. Set the geometry to 1024x1024 for your images. Specify .pvr format, enable pre-multiplied alpha, and toy with dithering (this may actually benefit some textures, ie improve on .png's). You could also probably benefit from RGBA4444 for menus (gain on memory required, with no significant loss on rendered quality).

You can also use the builtin texturetool as follows:

before you do this, you must convert toto.png to a POT file (1024x1024) in your case, with photoshop for example.

MrEvil:pvrCenter$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -m -f PVR -e PVRTC toto.png -o toto.pvr

MrEvil:pvrCenter$ gzip toto.pvr

this gives excellent compressions after a gzip (from 691Kb png to 295Kb).

I used texturetool because i can script that in shell, and process a whole lot of images with a single command (play D3 while the box churns out the images :) ).

EDIT 1 : some info on packing and file sizes.

ok, i started with one of my own 960x640 8 bits PNG, 691 Kb.

load it TexturePacker, set format to RBGA8888, 1024x1024, i get 766 Kb (this gives my my POT file).

export to RGBA8888 as a .pvr.ccz, 996 Kb. export to RGBA8888 as a .pvr.gz, 1.001 Mb export to RGBA4444 as a .pvr.ccz, 193Kb.

if i use texturetool on the 766 Kb file, then gzip the file 305Kb (RGBA8888). I cant really explain the difference between 305Kb and 996 Kb. It could be related to the dithering processing by TexturePacker, not certain.

于 2012-09-19T01:30:36.903 回答
0

是的,一定要使用纹理图集(精灵表不是正确的术语,但含义相同)。一个很好的工具是TexturePacker

纹理图集将在加载时节省时间,并节省内存。您还可以尝试不同的图像颜色深度和压缩选项,以进一步提高内存使用率和加载时间,但许多选项会在不同程度上影响图像质量,具体取决于您的图像。

顺便说一句,这些图像有多大?假设每个都是 512x512,并且您加载其中的 100 个,它们将消耗 100 MB 的内存。我提到这一点是因为这经常被忽视,并且磁盘上的文件大小只是图像作为纹理消耗的一小部分。

于 2012-09-18T22:39:48.720 回答