For quick games with extensive resources, Huawei offers a subpackage strategy. This approach allows a quick game package (up to 30 MB) to be divided into a main package and several subpackages based on specific rules. Players only download and load the main package upon entry; additional subpackages are downloaded on-demand during gameplay. This significantly reduces the initial loading time and minimizes data consumption.
Currently, released quick games with a package size exceeding 20 MB must be subpackaged.
├── assets
├── image
└── icons.png
└── 1.png
├── jsb-adapter
├── src
├── subpackages // Subpackage directory.
└── subpackageName1 // Subpackage 1.
└── game.js // Entry file of subpackage 1. The entry file of a subpackage must be named game.js.
└── main.js
└── subpackageName2 // Subpackage 2.
└── config.3dbbc.json
└── game.js // Entry file of subpackage 2. The entry file of a subpackage must be named game.js.
├── game.js // Entry file of the main package.
├── manifest.json // Configuration file.
{
...
"subpackages":[
{
"name":"subpackageName1", // Subpackage 1 name.
"resource":"subpackageName1" // Subpackage 1 path.
},{
"name":"subpackageName2", // Subpackage 2 name.
"resource":"subpackageName2" // Subpackage 2 path.
}
]
...
}
Files configured in subpackages will be packaged into several subpackages. Directories and files not configured in subpackages will be packaged into the main package.
Call qg.loadSubpackage in the entry file game.js of the main package to download the specified subpackage and load its game.js file.
var task = qg.loadSubpackage({
subpackage: 'subpackageName1',
success : function () {
console.log("loadSubpackage success");
},
fail:function(){
console.log("loadSubpackage fail");
},
complete:function() {
console.log("loadSubpackage complete");
}
});
mycallback(res){
console.log("onProgress" +JSON.stringify(res));
}
task.onprogress=this.mycallback Prior to release, you are advised to run and debug the subpackaged quick game in the latest version of QuickGameAssistant.