Commit 98c7544e authored by yu's avatar yu

结束老鼠,喇叭

parent aff6253c
This diff is collapsed.
...@@ -349,10 +349,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -349,10 +349,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
// head.active = true; // head.active = true;
// pg.view.setNetImg(head, quest.pic_url, { w: 550, h: 95 }); // pg.view.setNetImg(head, quest.pic_url, { w: 550, h: 95 });
// } // }
img_laba02.active = quest.audio_url; img_laba02.opacity = quest.audio_title ? 255 : 0;
if (quest.audio_url) { if (quest.audio_title) {
this.playLaba(img_laba02, question); this.playLaba(img_laba02, question);
cc.assetManager.loadRemote(quest.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(quest.audio_title, (err, audioClip) => {
question.audioClip = audioClip; question.audioClip = audioClip;
}); });
} }
...@@ -366,6 +366,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -366,6 +366,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
setTimeout(() => { setTimeout(() => {
if (desc.width - item.width > -15 && item.name != "type4") { if (desc.width - item.width > -15 && item.name != "type4") {
item.width = desc.width + 30; item.width = desc.width + 30;
img_laba02.opacity = data.audio_url ? 255 : 0;
} }
}, 30); }, 30);
item.on(cc.Node.EventType.TOUCH_END, () => { item.on(cc.Node.EventType.TOUCH_END, () => {
...@@ -374,7 +375,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -374,7 +375,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showAniFlower(item); this.showAniFlower(item);
}, 60); }, 60);
}) })
img_laba02.active = data.audio_url;
if (data.audio_url) { if (data.audio_url) {
this.playLaba(img_laba02, item); this.playLaba(img_laba02, item);
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
...@@ -400,7 +400,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -400,7 +400,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.showAniFlower(item); this.showAniFlower(item);
}, 60); }, 60);
}) })
img_laba02.active = data.audio_url; img_laba02.opacity = data.audio_url ? 255 : 0;
if (data.audio_url) { if (data.audio_url) {
this.playLaba(img_laba02, item); this.playLaba(img_laba02, item);
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
...@@ -491,10 +491,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -491,10 +491,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let img_laba01 = item.getChildByName("img_open"); let img_laba01 = item.getChildByName("img_open");
btn.on(cc.Node.EventType.TOUCH_END, () => { btn.on(cc.Node.EventType.TOUCH_END, () => {
if (item.audioClip) { if (item.audioClip) {
img_laba01.active = true; img_laba01.opacity = 255;
pg.audio.playAudio(item.audioClip, () => { pg.audio.playAudio(item.audioClip, () => {
// cc.audioEngine.stopAllEffects(); // cc.audioEngine.stopAllEffects();
img_laba01.active = false; img_laba01.opacity = 0;
// anim.stop(); // anim.stop();
}); });
} }
......
...@@ -14,6 +14,7 @@ class Emitter { ...@@ -14,6 +14,7 @@ class Emitter {
return this; return this;
} }
on(event, fn) { on(event, fn) {
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);
}; };
...@@ -25,7 +26,7 @@ class Emitter { ...@@ -25,7 +26,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 = {};
......
This diff is collapsed.
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