如何优雅的管理游戏资源 及 相关资料
2014-03-30 14:09
344 查看
understanding
pixel format in cocos2d v0.7.3
原文:http://www.sapusmedia.com/2009/05/understanding-pixel-format-in-cocos2d-v0-7-3-2/Since cosos2d v0.7.3, you can specify the texture’s pixel format of your PNG/TIFF/BMP/GIF images. The texture’spixel format is the
way the image is stored in GPU memory. Possible pixel formats:
RGBA8888 (32-bit) (kTexture2DPixelFormat_RGBA8888)
RGBA4444 (16-bit) (kTexture2DPixelFormat_RGBA4444)
RGB5_A1 (16-bit)(kTexture2DPixelFormat_RGB5A1)
RGB565 (16-bit) (kTexture2DPixelFormat_RGB565)
RGBA8888:
8 bits are assigned to the red channel, 8 bits
to the green channel, 8 bits to the blue channel and 8 bits
to the alpha channel.
Use this pixel format when you need the maximum possible quality for your image.
But it will consume the double of memory compared to 16-bit textures. Memory is a precious resource on the iPhone
Usually it is also slower to render.
Useful for: background image of your intro scene, and for images with lots of gradient colors
RGBA4444:
4 bits are assigned to the red channel, 4 bits
to the green channel, 4 bits to the blue channel, and 4 bits
to the alpha channel
It gives you good quality in all channels, good speed, good memory consumption.
Useful for: sprites that have different values of transparency
RGB5A1:
5 bits are assigned to the red channel, 5 bits
to the green channel, 5 bits to the blue channel, and only 1bit
to the alpha channel
It gives you good quality in RGB channels but poor quality on the A channel. It also gives you good speed and good memory consumption.
Useful for: sprites that have transparent parts, but the transparency is either On or Off
RGB565:
5 bits are assigned to the red channel, 6 bits
to the green channel, and 5 bits to the blue channel. It has no
alpha channel support
It gives you the best possible quality for 16-bit textures, but without alpha channel support.
Useful for: background images in your game.
The default pixel format in v0.7.3 is RGBA8888. How to use it:
// Set the pixel format before loading the image // RGBA 8888 image (32-bit) [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888]; Sprite *sprite1 = [Sprite spriteWithFile:@"test-rgba1.png"]; // Set the pixel format before loading the image // RGBA 4444 image (16-bit) [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444]; Sprite *sprite2 = [Sprite spriteWithFile:@"test-rgba2.png"]; // Set the pixel format before loading the image // RGB5A1 image (16-bit) [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGB5A1]; Sprite *sprite3 = [Sprite spriteWithFile:@"test-rgba3.png"]; // Set the pixel format before loading the image // RGB565 image (16-bit) [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGB565]; Sprite *sprite4 = [Sprite spriteWithFile:@"test-rgba4.png"]; // restore the default pixel format [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_Default]; |
A: No, PVRTC images have their own format. PVRTC images are faster and they consumes less memory
since they are either 2-bit or 4-bit textures but the quality is not that great.
Q: If I use 16-bit textures, will my game load faster ?
A: The texture pixel format has nothing to do with the loading times of your game. The Pixel
Format is how the image is stored in the GPU memory. If you want faster loading times you should reduce the size of you .PNG/GIF/TIFF/TMP image file.
Q: Should I use RGB565 for the images that are compressed by XCode ?
A: When XCode compresses the PNG images, it will create a compressed PNG image that has it’s
alpha channel premultiplied in the RGB channels. The PNG format is RGB565, but you should NOT confuse a PNG format with a texture pixel format. A PNG image is understood by Photoshop and cocos2d, but the GPU knows nothing about PNG images. The PNG images need
to be converted into a Texture (the format understood by the GPU). The answer is: it depends on what you want. The Image (PNG,GIF,TIFF,BMP) format is independent of the Texture format.
Q: If I create a PNG/BMP/TIFF/GIF image without alpha channel, can I change the texture pixel format ?
A: If your PNG/BMP/TIFF/GIF image has no alpha channel (premultiplied or not), then the pixel
format that will be used for the texture is RGB565. It can’t be changed using the API but you can change by modifying the Texture2D.m file
Q: Can I change the pixel format once the texture was created.
A: No. Once the Texture
was created you can’t modify the pixel format. But you can create new textures from the same image using different pixel formats. Just remember to remove the image from the TextureMgr!
(译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet(by 子龙山人)
原文地址:/article/4834725.html
如何优雅的管理游戏资源
原文地址:http://blog.leafsoar.com/archives/2013/11-27.html
相关文章推荐
- cocos2d:如何优雅的管理游戏资源
- 如何优雅的管理游戏资源
- 如何优雅的管理游戏资源
- 如何优雅的管理游戏资源
- cocos2d-x 如何管理游戏资源
- cocos2d-x 如何管理游戏资源
- 【转载】Unity 优雅地管理资源,减少占用内存,优化游戏
- 【C/C++】如何理解C/C++里的动态内存和资源管理
- 如何使用 CGroup 管理系统资源
- python 游戏开发相关资源站点
- 游戏中的资源管理--资源高速缓存
- 面试前如何搜集相关资料
- 第四章 Spring.Net 如何管理您的类___统一资源访问接口
- 【资源管理】游戏资源的压缩、打包与补丁更新
- 4张图让你了解:云管理平台系统如何进行资源管理的?
- Silverlight游戏设计(Game Design):(十四)练习用游戏素材资源的获取及相关工具使用心得
- [游戏] - 游戏中的资源管理----资源高速缓存
- 如何高效管理 React Native 项目中的图片资源
- 学php新手来看如何获得php相关资料?
- 如何管理国外同事、下属和老板,取全球资源建好团队