cocos2d里面使用精灵表单(spritesheet)的好处
来源:互联网 发布:细说php第一版 pdf 编辑:程序博客网 时间:2024/05/17 06:48
免责声明:本博客的所有原创文章,均有time_anime精心写作,供学习交流使用,切勿进行商业传播。同时,转载请不要移除本声明!
SpriteSheet精灵表单:每个游戏开发者都应该知道的基本概念。
看上图的游戏场景,它由不同的图形对象组成,有花、树、云朵和PixelGuy(就是那个小孩了)。所有这些可移动的游戏对象被称作精灵。
让我们看看一个特别的精灵,这个精灵是有着确定的像素宽度和高度的矩形图片。大小为140X140像素。
For eachpixel, some amount of memory is required to store its color. The exact amountdepends on the color depth - which is by default 32bit - and thus consumes 4bytes. So the complete memory usage of PixelGuy is 140x140x4 which is 76kb.
Dependingon your graphics hardware you might only be able to use particular sizes foryour sprites - e.g. a power of 2 or even worse - squared sprites.
For this asprite must be padded with additional unused pixels to match the hardware‘sconstraints. To meet this requirement PixelGuy‘s sprite must be extended to256x256 pixels. This increases the memory usage - now consuming 256kb - whichis more than three times the size of the original sprite.
Not muchfor a single sprite I must admit - but imagine creating a game with manyobjects, characters and animation phases. You might easily end up with hundredsof sprites - each of them wasting precious resources.
But what if youcould use the wasted memory after all? Imagine packing another sprite into thatspace!
The result is calleda sprite sheet!
Now only thecomplete sheet has to meet the hardware constraints. As you see the memoryusage is now much lower than it would be using individual sprites.
Butthere's still more we can do! Let‘s squeeze out the transparent parts of thesprites, packing them even tighter. In our example we have now reduced thememory by another 50%!
But wait!There's even more we can do - if memory is scarce. In a standard 32bit colorformat each color channel and the transparency is represented by 8 bits -totaling 4 bytes for each pixel. We can reduce the color depth to 16bit bysqueezing out some colors. The quality of the reduction can be improved byapplying dithering. The result reduces memory usage by 50%!
In thefirst part, you saw how sprite sheets can help you reduce memory usage for yourgame. In the second part, you are going to learn how the performance of yourgame can be increased with sprite sheets.
- cocos2d里面使用精灵表单(spritesheet)的好处
- cocos2d里面使用精灵表单(spritesheet)的好处
- SpriteSheet(精灵表单)的作用
- 深入理解SpriteSheet(精灵表单)概念
- 深入理解SpriteSheet(精灵表单)概念
- 深入理解SpriteSheet(精灵表单)概念
- (译)如何在cocos2d里面使用动画和spritesheet
- (译)如何在cocos2d里面使用动画和spritesheet
- (译)如何在cocos2d里面使用动画和spritesheet
- (译)如何在cocos2d里面使用动画和spritesheet
- (译)如何在cocos2d里面使用动画和spritesheet
- cocos2d-x学习笔记(16)--spritesheet(精灵表单)
- (译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- (译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- (译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- (译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- (牛文)(译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- (译)在cocos2d里面如何使用Texture Packer和像素格式来优化spritesheet
- java.lang.UnsatisfiedLinkError: no j3dcore-d3d in java.library.path
- table支持td字数长了后缀自动改为...(支持大多数浏览器)
- Hibernate设置长文本
- Linux安装jdk
- 深入理解 python 中的赋值、引用、拷贝、作用域
- cocos2d里面使用精灵表单(spritesheet)的好处
- Android extends和implements不同
- 内联函数和宏的区别(经典)
- HashMap详解
- 在Java中使用Memcached(转)
- Long2ObjectMap.Entry的用法
- 如何在cocos2d里面用TexturePacker制作可移动的炮炮兵动画
- 第一篇博客
- excel文档中数据导入sql server注意事项