Skip to content

Commit f56c202

Browse files
authored
Merge pull request rpgtkoolmv#182 from rev2nym/rpgtkoolmv#175-fix-frame-count
rpgtkoolmv#175 count frames at SceneManager
2 parents c6c371b + 1c42b55 commit f56c202

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

js/rpg_managers/DataManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ DataManager.setupNewGame = function() {
217217
$gamePlayer.reserveTransfer($dataSystem.startMapId,
218218
$dataSystem.startX, $dataSystem.startY);
219219
Graphics.frameCount = 0;
220+
SceneManager.resetFrameCount();
220221
};
221222

222223
DataManager.setupBattleTest = function() {

js/rpg_managers/SceneManager.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SceneManager._boxHeight = 624;
3030
SceneManager._deltaTime = 1.0 / 60.0;
3131
if (!Utils.isMobileSafari()) SceneManager._currentTime = SceneManager._getTimeInMsWithoutMobileSafari();
3232
SceneManager._accumulator = 0.0;
33+
SceneManager._frameCount = 0;
3334

3435
SceneManager.run = function(sceneClass) {
3536
try {
@@ -130,6 +131,18 @@ SceneManager.setupErrorHandlers = function() {
130131
document.addEventListener('keydown', this.onKeyDown.bind(this));
131132
};
132133

134+
SceneManager.frameCount = function() {
135+
return this._frameCount;
136+
};
137+
138+
SceneManager.setFrameCount = function(frameCount) {
139+
this._frameCount = frameCount;
140+
};
141+
142+
SceneManager.resetFrameCount = function() {
143+
this._frameCount = 0;
144+
};
145+
133146
SceneManager.requestUpdate = function() {
134147
if (!this._stopped) {
135148
requestAnimationFrame(this.update.bind(this));
@@ -263,6 +276,7 @@ SceneManager.updateScene = function() {
263276
this.onSceneStart();
264277
}
265278
if (this.isCurrentSceneStarted()) {
279+
this.updateFrameCount();
266280
this._scene.update();
267281
}
268282
}
@@ -276,6 +290,10 @@ SceneManager.renderScene = function() {
276290
}
277291
};
278292

293+
SceneManager.updateFrameCount = function() {
294+
this._frameCount++;
295+
};
296+
279297
SceneManager.onSceneCreate = function() {
280298
Graphics.startLoading();
281299
};

js/rpg_objects/Game_System.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Game_System.prototype.initialize = function() {
1616
this._winCount = 0;
1717
this._escapeCount = 0;
1818
this._saveCount = 0;
19-
this._frameCount = 0;
2019
this._versionId = 0;
2120
this._framesOnSave = 0;
21+
this._sceneFramesOnSave = 0;
2222
this._bgmOnSave = null;
2323
this._bgsOnSave = null;
2424
this._windowTone = null;
@@ -117,10 +117,6 @@ Game_System.prototype.saveCount = function() {
117117
return this._saveCount;
118118
};
119119

120-
Game_System.prototype.frameCount = function() {
121-
return this._frameCount;
122-
};
123-
124120
Game_System.prototype.versionId = function() {
125121
return this._versionId;
126122
};
@@ -169,29 +165,24 @@ Game_System.prototype.onBattleEscape = function() {
169165
this._escapeCount++;
170166
};
171167

172-
Game_System.prototype.onFrameUpdate = function() {
173-
this._frameCount++;
174-
};
175-
176168
Game_System.prototype.onBeforeSave = function() {
177169
this._saveCount++;
178170
this._versionId = $dataSystem.versionId;
179171
this._framesOnSave = Graphics.frameCount;
172+
this._sceneFramesOnSave = SceneManager.frameCount();
180173
this._bgmOnSave = AudioManager.saveBgm();
181174
this._bgsOnSave = AudioManager.saveBgs();
182175
};
183176

184177
Game_System.prototype.onAfterLoad = function() {
185-
if (!this._frameCount) {
186-
this._frameCount = this._framesOnSave;
187-
}
188178
Graphics.frameCount = this._framesOnSave;
179+
SceneManager.setFrameCount(this._sceneFramesOnSave || this._framesOnSave);
189180
AudioManager.playBgm(this._bgmOnSave);
190181
AudioManager.playBgs(this._bgsOnSave);
191182
};
192183

193184
Game_System.prototype.playtime = function() {
194-
return Math.floor(this._frameCount / 60);
185+
return Math.floor(SceneManager.frameCount() / 60);
195186
};
196187

197188
Game_System.prototype.playtimeText = function() {

js/rpg_scenes/Scene_Base.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Scene_Base.prototype.start = function() {
105105
* @memberof Scene_Base
106106
*/
107107
Scene_Base.prototype.update = function() {
108-
$gameSystem.onFrameUpdate();
109108
this.updateFade();
110109
this.updateChildren();
111110
};

0 commit comments

Comments
 (0)