/*:
* @plugindesc Fix the graphics jitter mostly noticeable when scrolling maps.
* @author Zumi Kua
*
* @help just enable this plugin, no need to do anything.
*/
/*: zh
* @plugindesc 修复游戏地图在滚动时不定时出现的卡顿感
* @author Zumi Kua
*
* @help 实际原因为performance.now返回的数值似乎会有误差,导致两帧之间的deltaTime在1/60上下来回横跳,进而导致在一次
* requestAnimationFrame回调中一次updateScene也没调用,然后在下一次requestAnimationFrame回调中连续调用两次updateScene
* 无法解决在非60Hz的显示器上的卡顿问题
*
* 使用requestAnimationFrame作为参数提供的DOMHighResTimeStamp似乎不会有该问题
*
*/
SceneManager.update = function(stamp) {
try {
this.tickStart();
if (Utils.isMobileSafari()) {
this.updateInputData();
}
this.updateManagers();
this.updateMain(stamp);
this.tickEnd();
} catch (e) {
this.catchException(e);
}
};
const DEBUG = false;
SceneManager.updateMain = function(stamp) {
if (Utils.isMobileSafari()) {
this.changeScene();
this.updateScene();
} else {
let fTime = (stamp - this._currentTime) / 1000;
if (fTime > 0.25) fTime = 0.25;
this._currentTime = stamp;
this._accumulator += fTime;
const old_ftime = fTime;
const old_accu = this._accumulator;
let i = 0;
while (this._accumulator >= this._deltaTime) {
i++;
this.updateInputData();
this.changeScene();
this.updateScene();
this._accumulator -= this._deltaTime;
}
if(DEBUG && i !== 1){
console.log(i, old_ftime, old_accu);
}
}
this.renderScene();
this.requestUpdate();
};