Commit de647dcf authored by yu's avatar yu

1

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