Commit de647dcf authored by yu's avatar yu

1

parent 5338880d
...@@ -6,12 +6,15 @@ import pg from "../../scene/pg_hy14_pipei"; ...@@ -6,12 +6,15 @@ import pg from "../../scene/pg_hy14_pipei";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class LayerBack extends cc.Component { export default class LayerBack extends cc.Component {
private btn_back: cc.Node; private btn_back: cc.Node;
private img_npc_voice: cc.Node; private img_npc_voice: cc.Node;
private bg_forbid: cc.Node;
onLoad() { onLoad() {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
...@@ -20,6 +23,7 @@ export default class LayerBack extends cc.Component { ...@@ -20,6 +23,7 @@ export default class LayerBack extends cc.Component {
initView() { initView() {
this.bg_forbid = pg.view.find(this, 'bg_forbid')
this.btn_back = pg.view.find(this, 'btn_back') this.btn_back = pg.view.find(this, 'btn_back')
this.label_title = pg.view.find(this, 'label_title') this.label_title = pg.view.find(this, 'label_title')
this.img_npc_voice = pg.view.find(this.label_title, 'img_npc_voice') this.img_npc_voice = pg.view.find(this.label_title, 'img_npc_voice')
...@@ -39,6 +43,7 @@ export default class LayerBack extends cc.Component { ...@@ -39,6 +43,7 @@ export default class LayerBack extends cc.Component {
pg.event.on('npc_layer_back_init', (data) => { pg.event.on('npc_layer_back_init', (data) => {
this.updateView(data); this.updateView(data);
if (!this.npcAudio) { if (!this.npcAudio) {
pg.view.visible(this.bg_forbid, false)
pg.event.emit('npc_voice_play_voice_end'); pg.event.emit('npc_voice_play_voice_end');
} else { } else {
this.playVoiceStart(); this.playVoiceStart();
...@@ -56,13 +61,14 @@ export default class LayerBack extends cc.Component { ...@@ -56,13 +61,14 @@ export default class LayerBack extends cc.Component {
this.schedule(this.playVoiceRunning, 0.3) this.schedule(this.playVoiceRunning, 0.3)
pg.audio.playAudioByUrl(this.npcAudio, () => { pg.audio.playAudioByUrl(this.npcAudio, () => {
this.playVoiceEnd(); this.playVoiceEnd();
pg.view.visible(this.bg_forbid, false)
pg.event.emit('npc_voice_play_voice_end') pg.event.emit('npc_voice_play_voice_end')
}, (audioId) => { }, (audioId) => {
this.audioId = audioId; this.audioId = audioId;
}); });
} }
playVoiceRunning() { playVoiceRunning() {
if (!this.img_npc_voice) { if(!this.img_npc_voice){
this.unschedule(this.playVoiceRunning) this.unschedule(this.playVoiceRunning)
return; return;
} }
...@@ -94,4 +100,3 @@ export default class LayerBack extends cc.Component { ...@@ -94,4 +100,3 @@ export default class LayerBack extends cc.Component {
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