Reducing build size

Hello!

I workaround build size on web desktop.

I create two texture atlases and by auto atlas. Build web-desktop and want to download only first atlas, and after some event in game download second atlas. Is it possible?

If no, this hack works? -> build with two atlases, remove one from resource folder, load via cc.loader.load(“path to static place in my server”, () => {}) and here add it by cc.textureCache ? another step to save it in local storage and then load it in next sessions.

Another question about prefabs. How to do same trick with prefabs? they have magic renaming and looks like mapping from settings.js with import folder. I have no idea how to hack this.

And future issue for speed up build process from cocos creator: put there checkbox “regenerate textures”. If marked - it will build like now, if not marked - creator will not pack textures, just use from last build. Now my game build times:
about 3 minutes compile and about 15 minutes packing textures.

for your first question
// 加载 Prefab
cc.loader.loadRes(“test assets/prefab”, function (err, prefab) {
var newNode = cc.instantiate(prefab);
cc.director.getScene().addChild(newNode);
});

// 加载 AnimationClip
var self = this;
cc.loader.loadRes(“test assets/anim”, function (err, clip) {
self.node.getComponent(cc.Animation).addClip(clip, “anim”);
});

// 加载 SpriteAtlas(图集),并且获取其中的一个 SpriteFrame
// 注意 atlas 资源文件(plist)通常会和一个同名的图片文件(png)放在一个目录下, 所以需要在第二个参数指定资源类型
cc.loader.loadRes(“test assets/sheep”, cc.SpriteAtlas, function (err, atlas) {
var frame = atlas.getSpriteFrame(‘sheep_down_0’);
sprite.spriteFrame = frame;
});
http://docs.cocos.com/creator/manual/zh/scripting/load-assets.html

http://docs.cocos.com/creator/manual/en/scripting/load-assets.html#how-to-dynamically-load
This may help you.

cc.loader.loadRes loads from build/assets/resources folder.
I want to remove all resources from build, and download them.
In attached link some information exists. But no answer on my questions.

When build with auto atlases on load first scene cocos try to load all of them.

Maybe, ordinary sprite atlases will help?

the dynamically loaded resources are really dynamically loaded.
http://docs.cocos.com/creator/manual/en/scripting/load-assets.html#how-to-dynamically-load


Is this what you want?

楼主的原意应该是通过网络远程加载图片 丢掉esources的束缚 打包的时候快速构建 他可能需要一套远程加载图片的方法 不过我记得cc.loader.loadRes也是可以加载的

maybe you need this

remoteUrl = "http://unknown.org/emoji?id=124982374";
cc.loader.load({url: remoteUrl, type: 'png'}, function () {
    // Use texture to create sprite frame
});

https://discuss.cocos2d-x.org/
There you can get more help.

resources文件夹就是动态加载的啊,远程加载限制比较多吧。