const {ccclass, property} = cc._decorator;

@ccclass
export default class ChatSoundPlay extends cc.Component {

    
    @property([cc.SpriteFrame])
    private pics:Array<cc.SpriteFrame> = []

    onLoad () {}

    private tick = 0;
    private index = 0;

    public isPlay = false;

    protected update(dt: number): void {
        if(this.isPlay){
            console.log('正在播放');
            this.tick += dt;
            if(this.tick >= 0.3){
                this.tick = 0;
                if(this.index >= 3){
                    this.index = 0;
                }
                this.node.getComponent(cc.Sprite).spriteFrame = this.pics[this.index];
                this.index += 1;
            } 
        }
        else{
            this.node.getComponent(cc.Sprite).spriteFrame = this.pics[3];
        }
    }

}