import { _decorator, Animation, AnimationClip, Component, Node, tween } from 'cc';
import { gameManager } from './gameManager';
const { ccclass, property } = _decorator;

@ccclass('addCoinAni')
export class addCoinAni extends Component {
    private m_reverse_call:any = null;

    public play(reverse_call){
        this.m_reverse_call = reverse_call;
        gameManager.playAddCoinSound()
        this.getComponent(Animation).play('add_coin_animation');
    }

    onNormalPlayFinish(){
        // this.getComponent(Animation).clips[0].wrapMode = AnimationClip.WrapMode.LoopReverse
        tween(this.node).delay(0.2).call(()=>{
            this.getComponent(Animation).play('add_coin_animation_reverse');
            if(this.m_reverse_call!=null){
                this.m_reverse_call()
            }
        }).start()
     
    }
}


