// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.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

cc.Class({
    extends: cc.Component,

    properties: {
        tiledMapAfter: cc.TiledMap,
        tiledMapOrigin: cc.TiledMap,
    },

    start () {
        window.game = this;
        var isAfter = true;
        // var isAfter = false;

        if (isAfter) {
            this.tiledMapOrigin.node.active = false;
        } else {
            this.tiledMapAfter.node.active = false;
        }

        this.addTimeLog();
    },

    addTimeLog () {
        let renderCount = 1;
        cc.director.on(cc.Director.EVENT_BEFORE_DRAW, ()=>{
            if (renderCount < 200) {
                console.time("render");
            }
        });
    
        cc.director.on(cc.Director.EVENT_AFTER_DRAW, ()=>{
            if (renderCount++ < 200) {
                console.timeEnd("render");
            }
        });


        // cc.director.on(cc.Director.EVENT_BEFORE_UPDATE, ()=>{
        //     if (renderCount < 200) {
        //         console.time("logic");
        //     }
        // });
    
        // cc.director.on(cc.Director.EVENT_AFTER_UPDATE, ()=>{
        //     if (renderCount++ < 200) {
        //         console.timeEnd("logic");
        //     }
        // });
    },

});
