const DWTool = require("../utils/DWTool");


cc.Class({
    extends: cc.Component,

    properties: {

        tempNode: cc.Node,
        shineSprite: cc.Sprite,
        countLabel: cc.RichText

    },


    init(count) {
        this.countLabel.string = `<img src='alert_coin'/><color=#584A47> ${DWTool.coinParse(count)}</c>`;
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad () {

    },

    start() {

        let finish = cc.callFunc(() => {
            this.shineSprite.node.runAction(cc.rotateBy(0.8, 100, 100).repeatForever())
        }, this);
        this.tempNode.scaleX = 0;
        this.tempNode.scaleY = 0;
        let sequence = cc.sequence(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()), finish);
        this.tempNode.runAction(sequence);
    },

    dissmiss() {
        let finish = cc.callFunc(() => {
            this.node.destroy();
        }, this);
        let sequence = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
        this.tempNode.runAction(sequence);
    },

    close() {
        this.dissmiss();
    },
});
