Commit aa8f9efe authored by Tt's avatar Tt

功能完成

parent da91fda0
...@@ -7,17 +7,12 @@ const { ccclass, property } = cc._decorator; ...@@ -7,17 +7,12 @@ const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class ImgAuto extends cc.Component { export default class ImgAuto extends cc.Component {
private img_npc_voice: cc.Node;
onLoad() { onLoad() {
this.initView();
this.initEvent(); this.initEvent();
} }
protected onDestroy(): void { protected onDestroy(): void {
this.unscheduleAllCallbacks(); this.unscheduleAllCallbacks();
} }
initView() {
this.img_npc_voice = this.node;
}
initEvent() { initEvent() {
pg.event.on('img_voice_play_voice_start', () => { pg.event.on('img_voice_play_voice_start', () => {
this.playVoiceStart(); this.playVoiceStart();
...@@ -34,10 +29,10 @@ export default class ImgAuto extends cc.Component { ...@@ -34,10 +29,10 @@ export default class ImgAuto extends cc.Component {
} }
playVoiceRunning() { playVoiceRunning() {
this.playVoiceCount++; this.playVoiceCount++;
if (!this.img_npc_voice) return; if (!this.node) return;
let p1 = this.img_npc_voice.getChildByName('p1') let p1 = this.node.getChildByName('p1')
let p2 = this.img_npc_voice.getChildByName('p2') let p2 = this.node.getChildByName('p2')
let p3 = this.img_npc_voice.getChildByName('p3') let p3 = this.node.getChildByName('p3')
p1.active = this.playVoiceCount % 3 == 0; p1.active = this.playVoiceCount % 3 == 0;
p2.active = this.playVoiceCount % 3 == 1; p2.active = this.playVoiceCount % 3 == 1;
p3.active = this.playVoiceCount % 3 == 2; p3.active = this.playVoiceCount % 3 == 2;
...@@ -45,9 +40,9 @@ export default class ImgAuto extends cc.Component { ...@@ -45,9 +40,9 @@ export default class ImgAuto extends cc.Component {
playVoiceEnd() { playVoiceEnd() {
this.unschedule(this.playVoiceRunning) this.unschedule(this.playVoiceRunning)
this.playVoiceCount = 0; this.playVoiceCount = 0;
let p1 = this.img_npc_voice.getChildByName('p1') let p1 = this.node.getChildByName('p1')
let p2 = this.img_npc_voice.getChildByName('p2') let p2 = this.node.getChildByName('p2')
let p3 = this.img_npc_voice.getChildByName('p3') let p3 = this.node.getChildByName('p3')
p1.active = true; p1.active = true;
p2.active = false; p2.active = false;
p3.active = false; p3.active = false;
......
This diff is collapsed.
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