|
@@ -156,7 +156,7 @@ cc.Class({
|
|
|
|
|
|
//设置初始预加载的子游戏
|
|
|
initPreSubGame(){
|
|
|
- /*
|
|
|
+ // /*
|
|
|
//临时生成节点
|
|
|
let tnode = new cc.Node('lab');
|
|
|
tnode.setPosition(-521, 272);
|
|
@@ -170,14 +170,15 @@ cc.Class({
|
|
|
tnode2.addComponent(cc.Label);
|
|
|
tnode2.getComponent(cc.Label).fontSize = 30;
|
|
|
tnode2.parent = this.node;
|
|
|
- */
|
|
|
-
|
|
|
+ // */
|
|
|
+ this.preLoadSubGameNums = 3; //预加载的子游戏个数
|
|
|
|
|
|
let obj = [
|
|
|
// {kindID: GameConstant.KIND_ID_NTIGER, weight: 30}, //老虎
|
|
|
// {kindID: GameConstant.KIND_ID_OLYMPUS, weight: 20}, //雷神
|
|
|
// {kindID: GameConstant.KIND_ID_FRUIT9X, weight: 10} //9线
|
|
|
];
|
|
|
+
|
|
|
for(let item of cc.vv.miniGameSort){
|
|
|
if(item.KindID == GameConstant.KIND_ID_NTIGER){
|
|
|
obj.push({kindID: GameConstant.KIND_ID_NTIGER, weight: 30});
|
|
@@ -189,6 +190,14 @@ cc.Class({
|
|
|
obj.push({kindID: GameConstant.KIND_ID_FRUIT9X, weight: 10});
|
|
|
}
|
|
|
}
|
|
|
+ obj.sort((a, b)=>{
|
|
|
+ return b.weight - a.weight;
|
|
|
+ });
|
|
|
+ if(obj.length > this.preLoadSubGameNums){
|
|
|
+ let lerp = obj.length - this.preLoadSubGameNums;
|
|
|
+ obj.splice(-lerp, lerp);
|
|
|
+ }
|
|
|
+
|
|
|
let str = JSON.stringify(obj);
|
|
|
let xx = Global.getLocalStorageVaule("preSubGames");
|
|
|
if(!xx){
|
|
@@ -674,7 +683,7 @@ cc.Class({
|
|
|
if(!bContain){ //当前进入的子游戏不在预加载子游戏列表中
|
|
|
//移除权重最低的子游戏
|
|
|
let tempName = config[preArr[0].kindID].bundle;
|
|
|
- // this.node.getChildByName('lab2').getComponent(cc.Label).string ='移除bundle: ' + tempName;
|
|
|
+ this.node.getChildByName('lab2').getComponent(cc.Label).string ='移除bundle: ' + tempName;
|
|
|
let bundle = cc.assetManager.getBundle(tempName);
|
|
|
if(bundle){
|
|
|
// window.nowBundle = null;
|
|
@@ -686,7 +695,11 @@ cc.Class({
|
|
|
preArr[0].kindID = optdata.KindID; //给移除的bundle重新赋值
|
|
|
preArr[0].weight = 30;
|
|
|
}
|
|
|
- // this.node.getChildByName('lab').getComponent(cc.Label).string =`当前bundle: ${config[preArr[0].kindID].bundle}:${preArr[0].weight}, ${config[preArr[1].kindID].bundle}:${preArr[1].weight}, ${ config[preArr[2].kindID].bundle}:${preArr[2].weight}`;
|
|
|
+ let des = '';
|
|
|
+ for(let i=0; i < preArr.length; i++){
|
|
|
+ des += config[preArr[i].kindID].bundle + ':' + preArr[i].weight + ' ';
|
|
|
+ }
|
|
|
+ this.node.getChildByName('lab').getComponent(cc.Label).string = '当前bundle: ' + des;
|
|
|
//修改本地缓存
|
|
|
let str = JSON.stringify(preArr);
|
|
|
Global.setLocalStorageVaule("preSubGames", str);
|