Commit 56d675c8 authored by zjz1994's avatar zjz1994

卡游戏显示默认北京页Bug

parent 27d77726
...@@ -96,9 +96,20 @@ export default class SceneCtrl { ...@@ -96,9 +96,20 @@ export default class SceneCtrl {
// scene.start(data); // scene.start(data);
// }, this); // }, this);
// scene.addEventListener(egret.Event.ADDED_TO_STAGE,this.sceneAddStateListener,this); // scene.addEventListener(egret.Event.ADDED_TO_STAGE,this.sceneAddStateListener,this);
let oldScene:Scene;
if(this.currentScene){
oldScene = this.currentScene;
}
scene.once(egret.Event.ADDED_TO_STAGE, () => { scene.once(egret.Event.ADDED_TO_STAGE, () => {
// console.log("addToStageListener",scene.skinName); // console.log("addToStageListener",scene.skinName);
scene.start(data); scene.start(data);
if(oldScene){
console.log("移除scene------------",oldScene.skinName);
oldScene.parent&&oldScene.parent.removeChild(oldScene);
oldScene.destroy();
oldScene = null;
}
}, this); }, this);
scene.onLoad().then(() => { scene.onLoad().then(() => {
// console.log("onLoad---after",scene.skinName); // console.log("onLoad---after",scene.skinName);
...@@ -126,18 +137,19 @@ export default class SceneCtrl { ...@@ -126,18 +137,19 @@ export default class SceneCtrl {
} }
private addToStage(scene: Scene) { private addToStage(scene: Scene) {
let oldScene: Scene; // let oldScene: Scene;
if (this._currentScene) { // if (this._currentScene) {
oldScene = this._currentScene; // oldScene = this._currentScene;
} // }
this._currentScene = scene; this._currentScene = scene;
this._parent.addChild(scene); this._parent.addChild(scene);
wait(1000).then(()=>{ // console.log("场景切换",scene.skinName,oldScene.skinName);
if(oldScene) { // wait(1000).then(()=>{
oldScene.destroy(); // if(oldScene) {
this._parent.removeChild(oldScene); // oldScene.destroy();
} // this._parent.removeChild(oldScene);
}); // }
// });
} }
_sceneClassMap: any; _sceneClassMap: any;
......
...@@ -417,6 +417,9 @@ export default class MainScene extends Scene { ...@@ -417,6 +417,9 @@ export default class MainScene extends Scene {
this.mapContainer = new egret.DisplayObjectContainer(); this.mapContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapContainer); this.addChild(this.mapContainer);
this.wormholeContainer = new egret.DisplayObjectContainer();
this.addChild(this.wormholeContainer);
//修改流沙的问题
this.mapupContainer = new egret.DisplayObjectContainer(); this.mapupContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupContainer); this.addChild(this.mapupContainer);
...@@ -479,6 +482,7 @@ export default class MainScene extends Scene { ...@@ -479,6 +482,7 @@ export default class MainScene extends Scene {
this.effectContainer.removeChildren(); this.effectContainer.removeChildren();
this.guideContainer.removeChildren(); this.guideContainer.removeChildren();
this.festivalContainer.removeChildren(); this.festivalContainer.removeChildren();
this.wormholeContainer.removeChildren();
} }
async start(data) { async start(data) {
super.start(); super.start();
...@@ -883,16 +887,6 @@ export default class MainScene extends Scene { ...@@ -883,16 +887,6 @@ export default class MainScene extends Scene {
this.map = bg; this.map = bg;
this.map.addChild(conveyor); this.map.addChild(conveyor);
this.wormholeContainer = new egret.DisplayObjectContainer();
this.addChild(this.wormholeContainer);
//修改流沙的问题
this.mapupContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupContainer);
//容器
this.elementContainer = new egret.DisplayObjectContainer();
this.addChild(this.elementContainer);
//加遮罩,大遮罩一直都加,小遮罩时时判断 //加遮罩,大遮罩一直都加,小遮罩时时判断
if(this.elementConMask){ if(this.elementConMask){
this.elementConMask.graphics.clear(); this.elementConMask.graphics.clear();
...@@ -1614,7 +1608,7 @@ export default class MainScene extends Scene { ...@@ -1614,7 +1608,7 @@ export default class MainScene extends Scene {
} }
removeEvents() { removeEvents() {
// console.log('mainscene-----移除事件监听------removeEvents'); console.log('mainscene-------removeEvents');
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this.settingBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_settingBtn, this); this.settingBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_settingBtn, this);
this.questionBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_questionBtn, this) this.questionBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_questionBtn, this)
...@@ -1633,11 +1627,6 @@ export default class MainScene extends Scene { ...@@ -1633,11 +1627,6 @@ export default class MainScene extends Scene {
this.propBtnCon.stepBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this) this.propBtnCon.stepBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_stepBtn, this)
//容器事件
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
this.reCoverAllLattice(); this.reCoverAllLattice();
//回收炮台相关动画 //回收炮台相关动画
for(var i=0;i<this.cannoEffect.length;i++){ for(var i=0;i<this.cannoEffect.length;i++){
...@@ -1661,6 +1650,10 @@ export default class MainScene extends Scene { ...@@ -1661,6 +1650,10 @@ export default class MainScene extends Scene {
} }
this.cannoEffect = new Array(); this.cannoEffect = new Array();
} }
destroy() {
console.log("mainscene-------------destroy");
super.destroy();
}
onEnterFrame() { onEnterFrame() {
if(this.enableTouch && !this.gameGuide) { if(this.enableTouch && !this.gameGuide) {
......
...@@ -741,7 +741,7 @@ export default class MapScene extends Scene { ...@@ -741,7 +741,7 @@ export default class MapScene extends Scene {
} }
destroy() { destroy() {
// console.log("map销毁"); console.log("map------------destroy");
super.destroy(); super.destroy();
// this.removeIcon(); // this.removeIcon();
...@@ -1238,6 +1238,7 @@ export default class MapScene extends Scene { ...@@ -1238,6 +1238,7 @@ export default class MapScene extends Scene {
} }
protected removeEvents(){ protected removeEvents(){
console.log("map-----------removeEvents");
this['goldBtn'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_goldBtn, this); this['goldBtn'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_goldBtn, this);
this['guide'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_guide, this); this['guide'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_guide, this);
// this['act2Btn'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_act2btn, this); // this['act2Btn'].removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_act2btn, this);
......
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