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

import pg from "./pg_hy04_pinci";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Candy extends cc.Component {
    @property(cc.Float)
    private jumpHeight: number = 80;
    private playVoiceCount: number;
    showAni() {
        return new Promise((resolve, reject) => {
            this.node.active = true;
            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);
                        resolve('');
                    }
                })
                // ch.runAction(ju);
                cc.tween(ch).sequence(ju, call).start();
                cc.tween(ch).delay(0.5).to(0.2, { opacity: 0 }).start();

            })
        });
    }
}



