// pg.event.emit('img_voice_play_voice_start')
// pg.event.emit('img_voice_play_voice_end')

import pg from "./pg_hy08_caici";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Candy extends cc.Component {

    @property(cc.Float)
    private jumpHeight: number = 80;
    onLoad() {
        this.initView();
        this.playVoiceStart();
    }
    initView() {
    }
    initEvent() {
        // pg.event.on('img_voice_play_voice_start', () => {
        //     this.playVoiceStart();
        // })
        // pg.event.on('img_voice_play_voice_end', () => {
        // })
    }
    private playVoiceCount: number;
    playVoiceStart() {
        this.node.children.forEach((ch, idx) => {
            let x = ch.x;
            let y = ch.y;
            ch.x = 0;
            ch.y = 0;
            let ju = cc.jumpBy(0.5, cc.v2(x, y), this.jumpHeight, 1);
            let call = cc.callFunc(() => {
                if (idx == this.node.children.length - 1)
                    pg.event.emit("camdy_action_end", this.node);
            })
            // ch.runAction(ju);
            cc.tween(ch).sequence(ju, call).start();

        })
    }
    playVoiceRunning() {

    }
}





