The overview includes the following 5 optimizations: Engine bottom-level optimization, texture optimization, rendering optimization, resource caching, and memory Optimization engine Optimization version 2.0 are optimized for the algorithm and more efficient than the 1.0 version. Version 2.0 uses the OpenGL ES 2.0 graphics library, and the 1.0 version uses OpenGL ES 1.0. Texture optimization
Textures are the most memory-intensive and degrade rendering rates.
The power of the second side
OpenGL in the request memory storage texture, is the power of 2 to apply for, that is, the corresponding 480*320 picture, it applies for the 512*512 space. Visible, there will be quite a lot of memory wasted. Therefore, we designed the picture, preferably a power of 2 square, or OpenGL eventually applied to 2 of the power of memory space.
Since not all images can be designed to be 2 power, they are solved by the "puzzle" method. This is the reason why you should use Texturepacker.
Color depth Optimization
The size of the memory that the picture occupies is calculated using this formula: height pixels * Width pixels * color depth. such as the color depth RGBA8888, is 32 bit, every 8bit is a byte, so a pixel of 4 bytes, is a shaper character size. Example. A 480*320 image size that accounts for memory 480*320*4 bytes.
In general, if the color requirements for the picture are not very high. ARGB8888 (4 bytes) can be changed to, ARGB1555 (2 bytes) (Transparent channel a 1 bits are generally used for image blending operations) or ARGB4444 (if not to do mixed operation, with 4 bit more appropriate). Or, if you do not need to use picture transparency, you do not need a channel, use RGB888 (3 bytes) directly to RGB565 (2 bytes). In this way, the final memory size of the picture takes up less space.
Texture compression format
The iOS system uses the PowerVR display chip to directly decode the PVR format, which can be read directly by iOS. However, this method is not suitable for Android and other platforms.
The PVR format actually turns the ARGB8888 into a ARGB1555 color deep for preservation.
Cocos2d-x 2.0.3 begins to support skeletal animation, and the cocos2dbuilder2.1 version can also be animated. It is also a good solution for memory optimization when working with animations.
Texture size Limits
Different device support texture size is not the same, iphone4 support is the largest 4096*4096,iphone4s is 4096*2048. Some Android devices are only limited to 1024*1024. Avoid putting too much of the picture in the puzzle. In order to improve the compatibility of the game, the image size is best set in the 1024*1024 range (mainstream devices are supported).
Render optimized batch Processing
With Ccspritebatchnode, the coordinate information of the sprite is prepared and rendered once.
Traditional rendering processing is like this: different switching textures, loading and rendering differently. Batch processing, however, increases the efficiency by loading all textures at once and then rendering them one at a time.
The resource cache Ccspriteframecachecctexturecache cache compares the power consumption, so the Remove function is called when the general usage is complete. and to display a progress bar when preloading, it may affect the user experience and should be used as appropriate. Memory-Optimized resource-intensive memory optimization as described in the previous subsections of the memory pool scenario when the game starts, it allocates a large chunk of space, and the game runs without releasing it until it exits the game. Instead of allocating memory for a new resource, the resource is loaded into the memory pool. When used multiple times, it is not necessary to release and reload multiple times. This section can learn more about the memory pool management mechanism of C + +.
Turn cocos2d-x optimization (Texture rendering optimization, resource caching, memory optimization)