Skip to content

Commit e64d6f4

Browse files
authored
Merge pull request rpgtkoolmv#171 from rpgtkoolmv/fix_playtime
Playtime ticked by game frames, not rendering frames
2 parents c684f72 + 9e7f13f commit e64d6f4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

js/rpg_objects/Game_System.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Game_System.prototype.initialize = function() {
1616
this._winCount = 0;
1717
this._escapeCount = 0;
1818
this._saveCount = 0;
19+
this._frameCount = 0;
1920
this._versionId = 0;
2021
this._framesOnSave = 0;
2122
this._bgmOnSave = null;
@@ -116,6 +117,10 @@ Game_System.prototype.saveCount = function() {
116117
return this._saveCount;
117118
};
118119

120+
Game_System.prototype.frameCount = function() {
121+
return this._frameCount;
122+
};
123+
119124
Game_System.prototype.versionId = function() {
120125
return this._versionId;
121126
};
@@ -164,6 +169,10 @@ Game_System.prototype.onBattleEscape = function() {
164169
this._escapeCount++;
165170
};
166171

172+
Game_System.prototype.onFrameUpdate = function() {
173+
this._frameCount++;
174+
};
175+
167176
Game_System.prototype.onBeforeSave = function() {
168177
this._saveCount++;
169178
this._versionId = $dataSystem.versionId;
@@ -173,13 +182,16 @@ Game_System.prototype.onBeforeSave = function() {
173182
};
174183

175184
Game_System.prototype.onAfterLoad = function() {
185+
if (!this._frameCount) {
186+
this._frameCount = this._framesOnSave;
187+
}
176188
Graphics.frameCount = this._framesOnSave;
177189
AudioManager.playBgm(this._bgmOnSave);
178190
AudioManager.playBgs(this._bgsOnSave);
179191
};
180192

181193
Game_System.prototype.playtime = function() {
182-
return Math.floor(Graphics.frameCount / 60);
194+
return Math.floor(this._frameCount / 60);
183195
};
184196

185197
Game_System.prototype.playtimeText = function() {

js/rpg_scenes/Scene_Base.js

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

0 commit comments

Comments
 (0)