How Cocos Creator optimizes package size

Cocos Creator package body composition and optimization techniques:

1: The bulk of the code volume (engine + business logic code setting.js) lies 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. If you can't use the module, don't use it . Cocos Creator is a good enough 2D editor that can replace tilemap and remove the tilemap logic.

As shown in the picture:

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

2: Image resources;

    Compression format of images: The size of background and jpg should be smaller than png, background image jpg, and many image formats. After exporting art images, these images can still be compressed. TinyPNG, etc.; Image resolution: 1920x1080 > 960x540; Just reduce the resolution.

    Use nine-square pictures as much as possible instead of a whole picture, which greatly reduces the resolution of the picture, thus saving resources;

    Image clarity: In fact, the compression algorithm can also adjust the clarity, png, and the number of quantization coefficients. The key information will become less and the clarity will decrease, but the resolution will not change;

   Pixel format of the picture: This is also possible, argb4444 is very rare, unless you are not in color.

   After the atlas is packaged, there will be space: blank space for organizing and adjusting;

   Number of pictures: The fewer the better, frame animation, reduce the number of frames, replace frame animation with skeletal animation to save resources;

 3: Music sound effects 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 will be doubled;

   Sampling rate: 1 second---》44100 sample, reduce the sampling rate, use compression software to do it, and video encoding tools to do it;          

   Background music: The size is generally relatively large, so 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 files;

    (2) Use system fonts as much as possible;

    (3) Fontmin can compress the font library and remove unused text from the font library to reduce the size;

     (4) Which one has better performance, bitmap words or appropriate words? Bitmap words: The speed is fast, but the memory is large. Moderate words, the speed is slow, but the memory is small.

Cocos creator package body optimization ends here

おすすめ

転載: blog.csdn.net/Unity_RAIN/article/details/134591742