// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import Cup from "./cup_PK_Game";

const { ccclass, property } = cc._decorator;

@ccclass
export default class HomeLayer extends cc.Component {

    @property(cc.Button)
    btn_start = null;
    @property(cc.Label)
    lb_gold = null;
    @property(cc.Label)
    lb_award = null;
    @property(cc.Label)
    lb_cost = null;
    _startCallBack: Function;

    onLoad() {
        this.btn_start.node.on("click", this.onClickStart, this);

        cc.tween(this.btn_start.node).to(0.3, { scale: 1.1 }).to(0.2, { scale: 1 }).delay(1).union().repeatForever().start();
    }

    onClickStart() {

        this._startCallBack && this._startCallBack();
    }

    initCup(score) {
        this.node.getChildByName("cup").getComponent(Cup).init(score, true);
    }
    set startCallBack(callback: Function) {
        this._startCallBack = callback;
    }
    // update (dt) {}
}
