Commit 5b7a1bd5 authored by Tt's avatar Tt

监听顺序修改

parent cd8cf56a
...@@ -29,7 +29,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -29,7 +29,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initData(); this.initData();
this.initView(); this.initView();
this.initListener(); this.initListener();
pg.event.on('npc_voice_play_voice_end', () => { pg.event.once('npc_voice_play_voice_end', () => {
this.initGame(); this.initGame();
}) })
pg.event.emit('npc_layer_back_init', this.data) pg.event.emit('npc_layer_back_init', this.data)
...@@ -437,17 +437,15 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -437,17 +437,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
} }
gameOver() { gameOver() {
this.sendData().then(() => { this.sendData().then(() => { })
pg.event.clear();
this.scheduleOnce(() => {
pg.view.visible(this.sentence_box, false) pg.view.visible(this.sentence_box, false)
// pg.event.emit('layer_ending_show', {
// coin: this.score
// })
// 下一页 // 下一页
pg.event.clear();
const middleLayer = cc.find('middleLayer').getComponent('middleLayer'); const middleLayer = cc.find('middleLayer').getComponent('middleLayer');
middleLayer.saveGolds(this.score); // 保存金币数量;num 是获得金币的数量,数字类型; middleLayer.saveGolds(this.score); // 保存金币数量;num 是获得金币的数量,数字类型;
middleLayer.goNextPage(); // 跳转到下一页 middleLayer.goNextPage(); // 跳转到下一页
}) }, 0.5)
} }
} }
......
...@@ -16,7 +16,8 @@ class Emitter { ...@@ -16,7 +16,8 @@ class Emitter {
clear() { clear() {
this._callbacks = {}; this._callbacks = {};
} }
on(event, fn) { on(event, fn: any) {
this.off(event);
if (!this._callbacks[event]) this._callbacks[event] = []; if (!this._callbacks[event]) this._callbacks[event] = [];
this._callbacks[event].push(fn); this._callbacks[event].push(fn);
}; };
...@@ -28,7 +29,7 @@ class Emitter { ...@@ -28,7 +29,7 @@ class Emitter {
on.fn = fn; on.fn = fn;
this.on(event, on); this.on(event, on);
}; };
off(event, fn) { off(event, fn?: any) {
// all // all
if (0 == arguments.length) { if (0 == arguments.length) {
this._callbacks = {}; this._callbacks = {};
......
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