Tuesday, June 14, 2022
HomeGame DevelopmentBundles are nonetheless loading after progress bar is completes - Cocos Creator

Bundles are nonetheless loading after progress bar is completes – Cocos Creator


Hello ,
I can see the load bundles logs after the progress bar is accomplished and web page is loaded the sport scene

In search of assistance on above talked about level.


It’s attainable that the logs are printed with a lag, are you able to present the main points?

Hello Linrm,
Thanks to your response!

So what occurs , bundles are loaded earlier than progress , we reached to foyer , we transfer to sport scene and we scene bundles are loading once more

Is bundles are loaded in response to scene?

If sure can’t we forcefully obtain all bundles collectively after which full the progress!

Attaching logs to your reference…

Additionally It will be useful when you can let me know methods to contact your V.I.P tech assist

Hello good friend, thanks for supporting cocos. If you wish to get V.I.P tech assist, please contact this e-mail yaqiong.liu@cocos.com and tell us some details about you, thanks.

Which model of creator are you utilizing? May you present your code of load bundle and progress bar?

I’m utilizing 2.4.7 model of creator

And we’re simply creating construct by selecting net construct on construct sort
And Please examine the beneath code connected for the code you requested

window.boot = operate () {
var settings = window._CCSettings;
window._CCSettings = undefined;
var onProgress = null;

var RESOURCES = cc.AssetManager.BuiltinBundleName.RESOURCES;
var INTERNAL = cc.AssetManager.BuiltinBundleName.INTERNAL;
var MAIN = cc.AssetManager.BuiltinBundleName.MAIN;
operate setLoadingDisplay () {
    // Loading splash scene
    var splash = doc.getElementById('splash');
    var progressBar = splash.querySelector('.progress-bar span');
    onProgress = operate (end, whole) {
        var p.c = 100 * end / whole;
        if (progressBar) {
            progressBar.fashion.width = p.c.toFixed(2) + '%';
        }
    };
    splash.fashion.show = 'block';
    progressBar.fashion.width="0%";

    cc.director.as soon as(cc.Director.EVENT_AFTER_SCENE_LAUNCH, operate () {
        splash.fashion.show = 'none';
    });
}

var onStart = operate () {

    cc.view.enableRetina(true);
    cc.view.resizeWithBrowserSize(true);

    if (cc.sys.isBrowser) {
        setLoadingDisplay();
    }

    if (cc.sys.isMobile) {
        if (settings.orientation === 'panorama') {
            cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
        }
        else if (settings.orientation === 'portrait') {
            cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
        }
        cc.view.enableAutoFullScreen([
            cc.sys.BROWSER_TYPE_BAIDU,
            cc.sys.BROWSER_TYPE_BAIDU_APP,
            cc.sys.BROWSER_TYPE_WECHAT,
            cc.sys.BROWSER_TYPE_MOBILE_QQ,
            cc.sys.BROWSER_TYPE_MIUI,
            cc.sys.BROWSER_TYPE_HUAWEI,
            cc.sys.BROWSER_TYPE_UC,
        ].indexOf(cc.sys.browserType) < 0);
    }

    // Restrict downloading max concurrent job to 2,
    // extra duties concurrently might trigger efficiency draw again on some android system / browsers.
    // You possibly can regulate the quantity primarily based by yourself check outcome, it's a must to set it earlier than any loading course of to take impact.
    if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) {
        cc.assetManager.downloader.maxConcurrency = 2;
        cc.assetManager.downloader.maxRequestsPerFrame = 2;
    }

    var launchScene = settings.launchScene;
    var bundle = cc.assetManager.bundles.discover(operate (b) {
        return b.getSceneInfo(launchScene);
    });
    
    bundle.loadScene(launchScene, null, onProgress,
        operate (err, scene) {
            if (!err) {
                cc.director.runSceneImmediate(scene);
                if (cc.sys.isBrowser) {
                    // present canvas
                    var canvas = doc.getElementById('GameCanvas');
                    canvas.fashion.visibility = '';
                    var div = doc.getElementById('GameDiv');
                    if (div) {
                        div.fashion.backgroundImage="";
                    }
                    console.log('Success to load scene: ' + launchScene);
                }
            }
        }
    );

};

var possibility = {
    id: 'GameCanvas',
    debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR,
    showFPS: settings.debug,
    frameRate: 60,
    groupList: settings.groupList,
    collisionMatrix: settings.collisionMatrix,
};

cc.assetManager.init({ 
    bundleVers: settings.bundleVers,
    remoteBundles: settings.remoteBundles,
    server: settings.server
});

var bundleRoot = [INTERNAL];
settings.hasResourcesBundle && bundleRoot.push(RESOURCES);

var depend = 0;
operate cb (err) {
    if (err) return console.error(err.message, err.stack);
    depend++;
    if (depend === bundleRoot.size + 1) {
        cc.assetManager.loadBundle(MAIN, operate (err) {
            if (!err) cc.sport.run(possibility, onStart);
        });
    }
}

cc.assetManager.loadScript(settings.jsList.map(operate (x) { return 'src/' + x;}), cb);

for (var i = 0; i < bundleRoot.size; i++) {
    cc.assetManager.loadBundle(bundleRoot[i], cb);
}

};

if (window.jsb) {
var isRuntime = (typeof loadRuntime === ‘operate’);
if (isRuntime) {
require(‘src/settings.07d9b.js’);
require(‘src/cocos2d-runtime.js’);
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
require(‘src/physics.js’);
}
require(‘jsb-adapter/engine/index.js’);
}
else {
require(‘src/settings.07d9b.js’);
require(‘src/cocos2d-jsb.js’);
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
require(‘src/physics.js’);
}
require(‘jsb-adapter/jsb-engine.js’);
}

cc.macro.CLEANUP_IMAGE_CACHE = true;
window.boot();

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments