Commit 9ce49c8a authored by zjz1994's avatar zjz1994

优化性能暂存

parent 89e088d3
...@@ -3,6 +3,7 @@ import Scene from "../components/Scene"; ...@@ -3,6 +3,7 @@ import Scene from "../components/Scene";
import Loading from "../components/Loading"; import Loading from "../components/Loading";
import wait from "../../new_tc/wait"; import wait from "../../new_tc/wait";
import MainScene from "../../../src/mainScene/MainScene"; import MainScene from "../../../src/mainScene/MainScene";
import MapScene from "../../../src/mapScene/MapScene";
export default class SceneCtrl { export default class SceneCtrl {
private _parent: egret.Sprite; private _parent: egret.Sprite;
private _currentScene: Scene; private _currentScene: Scene;
...@@ -11,6 +12,7 @@ export default class SceneCtrl { ...@@ -11,6 +12,7 @@ export default class SceneCtrl {
static _instance: SceneCtrl; static _instance: SceneCtrl;
mainscene:MainScene; mainscene:MainScene;
mapscene:MapScene;
static get instance() { static get instance() {
return SceneCtrl._instance || (SceneCtrl._instance = new SceneCtrl()) return SceneCtrl._instance || (SceneCtrl._instance = new SceneCtrl())
} }
...@@ -24,7 +26,7 @@ export default class SceneCtrl { ...@@ -24,7 +26,7 @@ export default class SceneCtrl {
} }
change(type: ModuleTypes, data?, onComplete?: Function) { change(type: ModuleTypes, data?, onComplete?: Function) {
if(type==ModuleTypes.MAIN_SCENE){ if(type==ModuleTypes.MAIN_SCENE){//游戏页
// console.log("游戏界面单例处理"); // console.log("游戏界面单例处理");
if(this.mainscene){ if(this.mainscene){
// console.log("使用已存在mainscene"); // console.log("使用已存在mainscene");
...@@ -44,11 +46,31 @@ export default class SceneCtrl { ...@@ -44,11 +46,31 @@ export default class SceneCtrl {
this.showAfterLoadAtlas(this.mainscene, data, onComplete); this.showAfterLoadAtlas(this.mainscene, data, onComplete);
} }
} }
}else{ }
// else if(type==ModuleTypes.MAP_SCENE){//mapscene
// if(this.mapscene){
// console.log("单例mapscene");
// this.showAfterLoadAtlas(this.mapscene,data,onComplete);
// }else{
// console.log("新建mapscene");
// this.mapscene = new MapScene();
// if (!window['development']) {
// const promise = Promise.all([
// RES.getResAsync(`${'Map'}_json`),
// RES.getResAsync(`${'Map'}_png`)]);
// promise.then(() => {
// this.showAfterLoadAtlas(this.mapscene, data, onComplete);
// });
// } else {
// this.showAfterLoadAtlas(this.mapscene, data, onComplete);
// }
// }
// }
else{
const cls = this._sceneClassMap[type]; const cls = this._sceneClassMap[type];
const scene: Scene = new cls(); const scene: Scene = new cls();
if (!window['development']) { if (!window['development']) {
if (type != ModuleTypes.MAP_SCENE) // if (type != ModuleTypes.MAP_SCENE)
Loading.instace.show(); Loading.instace.show();
const key = scene.skinKey.toLowerCase(); const key = scene.skinKey.toLowerCase();
const promise = Promise.all([ const promise = Promise.all([
......
...@@ -350,7 +350,7 @@ export default class MapScene extends Scene { ...@@ -350,7 +350,7 @@ export default class MapScene extends Scene {
RES.getResAsync(`${key}_png`)]); RES.getResAsync(`${key}_png`)]);
} catch (error) { } catch (error) {
} }
console.log("开始加载一系列资源");
RES.getResAsync('candydis0_json'); RES.getResAsync('candydis0_json');
RES.getResAsync('candydis1_json'); RES.getResAsync('candydis1_json');
RES.getResAsync('candydis2_json'); RES.getResAsync('candydis2_json');
...@@ -393,6 +393,7 @@ export default class MapScene extends Scene { ...@@ -393,6 +393,7 @@ export default class MapScene extends Scene {
loadSvga(getResPath() + 'resource/assets/svgas/sand_dis.svga'); loadSvga(getResPath() + 'resource/assets/svgas/sand_dis.svga');
// loadSvga(getResPath() + 'resource/assets/svgas/fireworks.svga'); // loadSvga(getResPath() + 'resource/assets/svgas/fireworks.svga');
console.log("一系列资源加载完毕");
if (!window['development']) { if (!window['development']) {
RES.getResAsync(`inviterulepanel_json`); RES.getResAsync(`inviterulepanel_json`);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment