var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var SceneManager = (function () {
    function SceneManager(parent) {
        this._parent = parent;
        this._sceneObj = {};
    }
    SceneManager.prototype.startTick = function () {
        this._curTime = egret.getTimer();
        egret.startTick(this.tick, this);
    };
    SceneManager.prototype.stopTick = function () {
        egret.stopTick(this.tick, this);
    };
    SceneManager.prototype.tick = function (advancedTime) {
        this._lastTime = this._curTime;
        this._curTime = advancedTime;
        if (this._curScene) {
            this._curScene.tick(this._curTime - this._lastTime);
        }
        return true;
    };
    SceneManager.prototype.registerScene = function (name, scene) {
        this._sceneObj[name] = scene;
    };
    SceneManager.prototype.setCurSceneByName = function (name) {
        var scene = this._sceneObj[name];
        if (scene) {
            this.setCurScene(scene);
        }
    };
    SceneManager.prototype.setCurScene = function (scene) {
        if (this._curScene) {
            this._curScene.removeEventListener(SceneEvent.NEXT, this.onNext, this);
            this._prevScene = this._curScene;
        }
        this._curScene = scene;
        this._curScene.show(this._parent);
        this._curScene.addEventListener(SceneEvent.NEXT, this.onNext, this);
    };
    SceneManager.prototype.onNext = function (e) {
        var scene = this._sceneObj[e.data];
        if (scene) {
            this.setCurScene(scene);
        }
    };
    return SceneManager;
}());
__reflect(SceneManager.prototype, "SceneManager");
//# sourceMappingURL=SceneManager.js.map