cc.Class({
    extends: cc.Component,

    properties: {
        readyGoAudio: {
            default: null,
            type: cc.AudioSource,
            serializable: true,  
        },
    },
    onLoad () {
        this.armatureDisplay = this.node.getComponent(dragonBones.ArmatureDisplay);
        this.armature = this.armatureDisplay.armature();
        //添加动画事件监听
        this.armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this);
        this.armatureDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT, this.animationEventHandler_Enter, this);
    },
    Play(callback)
    {
        this.callback = callback;
        this.armature.animation.play("animation", 1);
        this.readyGoAudio.play();
    },
    animationEventHandler(event) 
    {
        if (event.type === dragonBones.EventObject.COMPLETE) {
            //主角
            if (event.animationState.name === "animation") {
                this.callback();
            }
        }
    },
    animationEventHandler_Enter(event) {

    },
});
