Tips to reduce the download size

1

Stats

6,709 visits, 9,420 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 12 Dec, 2014. Last updated 19 Feb, 2019

There are a few tricks you can use to ensure the download size of your project is as small as possible. Here's a few options to look at.

Image formats

By default, Construct 2 exports everything as PNG-32, regardless of the format of the image you originally imported. However any images with under 256 colors automatically get exported as PNG-8.

Any photographic images, or other detailed images which don't need an alpha channel, can be set to use JPEG format instead. JPEG is lossy, but produces far smaller files for these types of images. You can set individual images to export as JPEG with the Image format dialog, accessible from the image editor toolbar.

You can also choose a quality value from 0-100 for the JPEG format. Lower quality values produce smaller files, but are more likely to degrade the image appearance with compression artefacts.

For images using an alpha channel, choosing PNG-8 is also lossy (possibly degrading the image quality), but can produce smaller files. Construct 2 uses an advanced dithering algorithm to create a PNG-8 file that looks as close as possible to the original, depsite the fact the PNG-8 format can only use 256 different colors in one image.

The image format dialog allows you to choose the image format setting for individual frames, the entire animation, the entire object, or the entire project. Be careful when choosing it for the entire project, since it will replace all other settings, including any set to use JPEG.

Use low-resolution images where possible

If the project Sampling property is Linear, then images stretched up get a soft slightly blurry appearance as it smoothly blends between pixels to fill the extra space. You can take advantage of this to make low-contrast images (anything which already has a soft or blurry appearance) use a smaller source image.

For example here is a 320x240 image shown at 100% scale in the layout:

If the original image is stretched down to half the size (160x120), then stretched up back to the original size in the layout view with linear sampling, it looks very similar:

Here's a side-by-side comparison. There is a subtle difference, but for this type of image it's quite hard to spot without looking closely.

This can be taken even further by scaling down by even greater amounts such as 3x, 4x or more. Since the original image is smaller, its image file will likely be a lot smaller. As an added bonus it will also use less memory. In this example the 320x240 image exports to a 59.3kb PNG, and the 160x120 image exports to 20.3kb, which is a saving of about 66%. A similar percentage saving should be seen with even larger images.

Reducing audio size

Remember Construct 2 dual-encodes all your audio in to Ogg Vorbis (.ogg) and AAC (.m4a) to support all platforms and browsers. On some platforms, you only need one set of files. Normally Construct 2 only exports one set of files if the export option you have chosen is known to support that set of files. For example it only exports the .ogg files and skips the .m4a files when exporting for NW.js since it knows NW.js supports Ogg Vorbis.

If for some reason you are exporting and have both sets of audio files, but you know you'll only need one of them, then you can delete the other set of audio files and save on the download size. You don't need to do this for HTML5 websites, since the browser only downloads files it knows it supports, but for some platforms you need to provide a zip of all your project files which will all be downloaded.

AAC files (.m4a) are only necessary for Safari (or any export for iOS) and Internet Explorer (or any export for the Windows Store). Both sets of files are necessary on the web in case someone views the game with Safari or Internet Explorer. However if you are targeting a specific platform it's worth double checking that you only have the one necessary set of audio files.

Recompressing audio can also further reduce the audio file size at the expense of quality. You can also further reduce audio size by downmixing stereo audio to mono. Often on mobile this is acceptable since few mobile devices have good enough speakers for low bitrate audio or mono sounds to be noticable. Since Construct 2 has limited options for encoding audio, consider using separate specialist audio software to recompress audio files to achieve the best balance between file size and quality.

Cut anything you don't need

This can be tricky, but if there are any sound effects, music tracks, or images used that can be removed, this will save them from adding to the download size. Also any long sound effects or music tracks could be edited to be shorter.

Remember Construct 2 still exports object images and audio files even if you never use them - so delete anything you don't use from the project.

Minify and recompress on export

When exporting, be sure to tick Minify script to ensure the resulting Javascript file is as small as possible. You should also have PNG recompression set to at least Standard, since this makes sure it runs all of Construct 2's export-time optimisations which includes recompressing image files to save as much space as possible. The Brute mode may save another few percent of the download size, but can take an extraordinarily long time to export, so may be undesirable for that reason.

Construct 2's download size estimate

In the status bar, Construct 2 attempts to estimate the download size of the game. This should only be considered a very rough guess. All the optimisations like spritesheeting and recompression on export can significantly change the download size, and the final results also depend on the exact content of the project. Therefore to test improvements to your download size, do not rely on the guess in the status bar: you should actually fully export the project and check the size of the resulting folder to determine the real download size, and measure the impact of any changes.

Conclusion

Most of a project's download size consists of the image files and audio files. By ensuring images and audio use the best compression possible you can make significant savings to your project's download size.

  • 0 Comments

Want to leave a comment? Login or Register an account!