diff --git a/js/rpg_managers/DataManager.js b/js/rpg_managers/DataManager.js index 8c59e044..9ddcc62f 100644 --- a/js/rpg_managers/DataManager.js +++ b/js/rpg_managers/DataManager.js @@ -217,6 +217,7 @@ DataManager.setupNewGame = function() { $gamePlayer.reserveTransfer($dataSystem.startMapId, $dataSystem.startX, $dataSystem.startY); Graphics.frameCount = 0; + SceneManager.resetFrameCount(); }; DataManager.setupBattleTest = function() { diff --git a/js/rpg_managers/SceneManager.js b/js/rpg_managers/SceneManager.js index 77fc95c1..5b1f13ce 100644 --- a/js/rpg_managers/SceneManager.js +++ b/js/rpg_managers/SceneManager.js @@ -30,6 +30,7 @@ SceneManager._boxHeight = 624; SceneManager._deltaTime = 1.0 / 60.0; if (!Utils.isMobileSafari()) SceneManager._currentTime = SceneManager._getTimeInMsWithoutMobileSafari(); SceneManager._accumulator = 0.0; +SceneManager._frameCount = 0; SceneManager.run = function(sceneClass) { try { @@ -130,6 +131,18 @@ SceneManager.setupErrorHandlers = function() { document.addEventListener('keydown', this.onKeyDown.bind(this)); }; +SceneManager.frameCount = function() { + return this._frameCount; +}; + +SceneManager.setFrameCount = function(frameCount) { + this._frameCount = frameCount; +}; + +SceneManager.resetFrameCount = function() { + this._frameCount = 0; +}; + SceneManager.requestUpdate = function() { if (!this._stopped) { requestAnimationFrame(this.update.bind(this)); @@ -263,6 +276,7 @@ SceneManager.updateScene = function() { this.onSceneStart(); } if (this.isCurrentSceneStarted()) { + this.updateFrameCount(); this._scene.update(); } } @@ -276,6 +290,10 @@ SceneManager.renderScene = function() { } }; +SceneManager.updateFrameCount = function() { + this._frameCount++; +}; + SceneManager.onSceneCreate = function() { Graphics.startLoading(); }; diff --git a/js/rpg_objects/Game_System.js b/js/rpg_objects/Game_System.js index 0f7a98c2..1613581d 100644 --- a/js/rpg_objects/Game_System.js +++ b/js/rpg_objects/Game_System.js @@ -16,9 +16,9 @@ Game_System.prototype.initialize = function() { this._winCount = 0; this._escapeCount = 0; this._saveCount = 0; - this._frameCount = 0; this._versionId = 0; this._framesOnSave = 0; + this._sceneFramesOnSave = 0; this._bgmOnSave = null; this._bgsOnSave = null; this._windowTone = null; @@ -117,10 +117,6 @@ Game_System.prototype.saveCount = function() { return this._saveCount; }; -Game_System.prototype.frameCount = function() { - return this._frameCount; -}; - Game_System.prototype.versionId = function() { return this._versionId; }; @@ -169,29 +165,24 @@ Game_System.prototype.onBattleEscape = function() { this._escapeCount++; }; -Game_System.prototype.onFrameUpdate = function() { - this._frameCount++; -}; - Game_System.prototype.onBeforeSave = function() { this._saveCount++; this._versionId = $dataSystem.versionId; this._framesOnSave = Graphics.frameCount; + this._sceneFramesOnSave = SceneManager.frameCount(); this._bgmOnSave = AudioManager.saveBgm(); this._bgsOnSave = AudioManager.saveBgs(); }; Game_System.prototype.onAfterLoad = function() { - if (!this._frameCount) { - this._frameCount = this._framesOnSave; - } Graphics.frameCount = this._framesOnSave; + SceneManager.setFrameCount(this._sceneFramesOnSave || this._framesOnSave); AudioManager.playBgm(this._bgmOnSave); AudioManager.playBgs(this._bgsOnSave); }; Game_System.prototype.playtime = function() { - return Math.floor(this._frameCount / 60); + return Math.floor(SceneManager.frameCount() / 60); }; Game_System.prototype.playtimeText = function() { diff --git a/js/rpg_scenes/Scene_Base.js b/js/rpg_scenes/Scene_Base.js index 88b97374..4ab0e6a6 100644 --- a/js/rpg_scenes/Scene_Base.js +++ b/js/rpg_scenes/Scene_Base.js @@ -105,7 +105,6 @@ Scene_Base.prototype.start = function() { * @memberof Scene_Base */ Scene_Base.prototype.update = function() { - $gameSystem.onFrameUpdate(); this.updateFade(); this.updateChildren(); };