Cocos Creator Tutorial: How to optimize package size

The composition and optimization skills of Cocos Creator package body:

1: The bulk of the code volume (engine + business logic code setting.js) is in the engine; engine optimization is very simple, you just need to remove the unnecessary modules, you need to know which modules take up a lot of volume, such as the physics engine, You don't need any modules that you can't use. Cocos creator is a good enough 2D editor to replace tilemap and remove tilemap logic.

As shown in the figure:

Business logic code: Generally, we can't modify it. Your business logic is similar. However, you should pay attention to a fact that more than 95% of your classmates will ignore: who decides the size of setting.js and setting.js? The number of files in resources, and the resources loaded by non-code, I must release the resources module.

2: image resource;

Image compression format: background, jpg should be smaller than png, background image jpg, many image formats, after exporting art images, these images can still be compressed. TinyPNG, etc.; image resolution: 1920x1080 > 960x540; just reduce the resolution.

Use the picture of Jiugongge as much as possible to replace a whole picture, which greatly reduces the bin rate of the picture, so that resources can be saved;

Image clarity: In fact, the compression algorithm can also adjust the clarity, png, adjust the quantization coefficient, the key information becomes less, the clarity will decrease, but the resolution will not change;

The pixel format of the picture: This is also possible, argb4444 is very small, unless you are not color.

After the atlas is packaged, there is an open space: empty space, organize, adjust;

Number of pictures: the less the better, frame animation, reduce the number of frames, skeletal animation replaces frame animation, save resources;

3: Music sound effect resources (compression format, size of background music, number of music, channels, sampling rate);

Compression format: WAV ---> volume mp3, ogg,

Channel: two-channel data, then at this time, the volume is doubled;

Sampling rate: 1 second---"44100 sample, reduce the sampling rate, compression software to do it, video encoding tool to do it;

Background music: The volume is generally relatively large, and it should be optimized first if possible;

4: Font library:

(1) For special effect text, try to use bitmap fonts, a few letters + pictures, the volume is much smaller than a complete font library, and the performance is even better; such as numbers, interface text, bmpfont ---> .png + .fnt file;

(2) Use the system font as much as possible;

(3) fontmin can compress the font library, remove the unused text from the font library, and reduce the volume;

(4) Bitmap word or appropriate word, which one has better performance? Bitmap word: Fast speed, but large memory, moderate word, slow speed but small memory.

Cocos creator package body optimization is here,

 

Guess you like

Origin blog.csdn.net/bycw666/article/details/123421654