import {playAudioByUrl, playDragonBoneAnimation} from "../script/util";

cc.Class({
    extends: cc.Component,
    name: "Mouse",
    properties: {
        showTitle:{
            default:null,
            type: cc.Label
        },

        
    },

    init(){
        playDragonBoneAnimation(this.node, 'normal', -1);
    },

    setTitle(text){
        this.showTitle.string = text;
        this.showTitle.node.opacity = 255;
    },

    playAudio(){
        if (this.audio && this.audio!=""){
            playAudioByUrl(this.audio);
        }
    },

    hit(){
        cc.tween(this.showTitle.node)
            .delay(0.17)
            .to(0.5-0.17, {opacity: 0})
            .start();

        playDragonBoneAnimation(this.node, 'wrong', 1, ()=>{
            
        });

        cc.tween(this.node)
        .delay(0.75)
        .call(()=>{
            WL.afterHit(this.node);
        })
        .start();
    }



});