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

import pg from "../../scene/tool/pg_hy02_paopao";





const { ccclass, property } = cc._decorator;

@ccclass
export default class Candy extends cc.Component {
    @property(cc.Float)
    private jumpHeight: number = 80;
    @property(cc.Boolean)
    private isHide: boolean = false;
    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);
                if (this.isHide) this.node.active = !this.isHide;
            })
            // ch.runAction(ju);
            cc.tween(ch).sequence(ju, call).start();

        })



    }
    playVoiceRunning() {

    }
}



