Download Images png/jpg to disk for native

Download Images png/jpg to disk for native
0

Hello, I’m trying to decrease my game size for native version Android/iOS I have tried tinypng but yet it’s not less then 100mb for app submission, all of the assets such as images/sounds are built in the APK/IPA package. I’ve play around with jsb.fileUtils.createDirectory(directory); for create directory with getWritablePath() but how can I save it to disk using cc.loader.load I’ve done some research and found AssetsManager for here and there but none api reference or document was found.

Basically I need to download Images and Sounds if possible to the devices first and use it from there.

Hello minhtrungaa. I’ve tried to seperate rgb and alpha channels of PNG images and put side by side in a JPEG and use custom shader to merge rgb and a when rendering. So I could save a lot of space for my game. JPEG format has a huge room for compression quality compared to PNG. You can find my forum post here:

Later I developed it and made my own sprite atlas generator to arrange rgb and alpha channels.

Hope it helps :wink:

Thanks for quick replied, your solution works like a charm for compress our atlas the size reduces around 40% but yet my game is around ~600mb in size unfortunately because we have a lot of assets that use in many separated level :frowning: while with your solutions my game size is around 200mb now that’s huge but yet, Can we actually implement a way to download data from remote server to devices on first launch?

1 Like

try “hot update” feature
https://docs.cocos.com/creator/manual/en/advanced-topics/assets-manager.html

Great Ideal, I came up with a basic flow using hot update

  1. Generate manifest file after build and upload res directory to remote server

  2. Deletes all the the raw assets in build dir and re generate manifest file for client native

  3. APK/IPA will having no assets in it by before actually Compile and Link native version

I’ll come back with the result later thanks you guys all.

1 Like