
const {ccclass, property} = cc._decorator;

@ccclass
export default class candle extends cc.Component {

    @property(dragonBones.ArmatureDisplay)
    dragon1 : dragonBones.ArmatureDisplay=null;
    @property(dragonBones.ArmatureDisplay)
    dragon2 : dragonBones.ArmatureDisplay=null;
    @property(cc.Node)
    mask:cc.Node;
   

    // LIFE-CYCLE CALLBACKS:

    onLoad () {}

    start () {
        this.dragon1.playAnimation("newAnimation",-1)
        this.dragon2.playAnimation("newAnimation",-1)
    }

    public init(): void {
        this.dragon1.node.active = true;
        this.dragon2.node.active = false;
        this.node.height = 333;
        this.mask.height = 333;
    }

    public changeShow(){
        this.dragon1.node.active = false;
        this.dragon2.node.active = true;
    }

    public changHeight(change: number)
    {
        this.mask.height -= change;
        this.node.height -= change;

        if(this.mask.height < 0){
            this.mask.height = this.node.height = 0;
        }

        if(this.mask.height <= 333 * 0.2)
        {
            this.changeShow();
        }
    }

    public isTimeEnd(){
        return this.mask.height <= 0;
    }

    // update (dt) {}
}
