import pg from "./pg";

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        let panel_gray = pg.view.find(this, "panel_gray");
        let btn_start = pg.view.find(this, "btn_start");
        let btn_restart = pg.view.find(this, "btn_restart");
        let bg_vs = pg.view.find(this, "bg_vs");
        pg.view.touchOn(btn_start, this.onTouchStart, this);
        panel_gray.active = true;
        btn_start.active = true;
    }
    onTouchStart() {
        let panel_gray = pg.view.find(this, "panel_gray");
        let btn_start = pg.view.find(this, "btn_start");
        let btn_restart = pg.view.find(this, "btn_restart");
        let bg_vs = pg.view.find(this, "bg_vs");
        panel_gray.active = true;
        btn_start.active = false;
        bg_vs.active = true;
        setTimeout(() => {
            bg_vs.active = false;
            panel_gray.active = false;
            pg.event.emit("game_start")
        }, 100);
    }
    update(dt) { }
}
