アツマール版Community_basicを参考にしてfpsを制御する事自体は上手くいきましたが、オプションで変更したものが反映されません。半日ぐらい粘りましたが問題点が見つかりませんでしたので、指南をお願いしたいです。
1.アツマール版Community_basicを参考にfpsを制御し箇所
コード: 全て選択
var currentTime = Date.now();
var deltaTime = 1000 / ConfigManager.fpsControl;
var accumulator = 0;
var _SceneManager_renderScene = SceneManager.renderScene;
SceneManager.renderScene = function() {
var newTime = Date.now();
accumulator += newTime - currentTime;
currentTime = newTime;
if (accumulator >= deltaTime) {
accumulator -= deltaTime;
_SceneManager_renderScene.apply(this, arguments);
}
};
})();
2.ConfigManager.fpsControlの初期値(この初期値60を弄るとフレームレートが変わる)
コード: 全て選択
ConfigManager.alwaysDashOnOff = false;
ConfigManager.commandRememberOnOff = false;
ConfigManager.fpsControl = 60;
3.ConfigManager(上手くいってない箇所候補。その1)多分最有力箇所
コード: 全て選択
ConfigManager.makeData = function() {
var config = {};
config.alwaysDashOnOff = this.alwaysDashOnOff;
config.commandRememberOnOff = this.commandRememberOnOff;
config.bgmVolume = this.bgmVolume;
config.bgsVolume = this.bgsVolume;
config.meVolume = this.meVolume;
config.seVolume = this.seVolume;
config.fpsControl = this.fpsControl;
return config;
};
ConfigManager.applyData = function(config) {
this.alwaysDashOnOff = this.readFlag(config, 'alwaysDashOnOff');
this.commandRememberOnOff = this.readFlag(config, 'commandRememberOnOff');
this.bgmVolume = this.readVolume(config, 'bgmVolume');
this.bgsVolume = this.readVolume(config, 'bgsVolume');
this.meVolume = this.readVolume(config, 'meVolume');
this.seVolume = this.readVolume(config, 'seVolume');
this.fpsControl = this.readFpsValue(config, 'fpsControl');
};
ConfigManager.readFlag = function(config, name) {
return !!config[name];
};
ConfigManager.readVolume = function(config, name) {
var value = config[name];
if (value !== undefined) {
return Number(value).clamp(0, 100);
} else {
return 100;
}
};
ConfigManager.readFpsValue = function(config, name) {
var value = config[name];
if (value !== undefined) {
return Number(value).clamp(15, 60);
} else {
return 60;
}
};
3.Window_Options(上手くいってない箇所候補。その2)
コード: 全て選択
Window_Options.prototype.addVolumeOptions = function() {
this.addCommand("フレームレート", 'fpsControl');
this.addCommand(TextManager.bgmVolume, 'bgmVolume');
this.addCommand(TextManager.bgsVolume, 'bgsVolume');
this.addCommand(TextManager.meVolume, 'meVolume');
this.addCommand(TextManager.seVolume, 'seVolume');
};
Window_Options.prototype.drawItem = function(index) {
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var titleWidth = rect.width - statusWidth;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawText(this.commandName(index), rect.x, rect.y, titleWidth, 'left');
this.drawText(this.statusText(index), titleWidth, rect.y, statusWidth, 'right');
};
Window_Options.prototype.statusWidth = function() {
return 120;
};
Window_Options.prototype.statusText = function(index) {
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
return this.volumeStatusText(value);
} else if(this.isBooleanSymbol(symbol)){
return this.booleanStatusText(value);
} else if(this.isFpsSymbol(symbol)){
return this.fpsStatusText(value);
} else {
return ""
}
};
Window_Options.prototype.isVolumeSymbol = function(symbol) {
return symbol.contains('Volume');
};
Window_Options.prototype.isBooleanSymbol = function(symbol) {
return symbol.contains('OnOff');
};
Window_Options.prototype.isFpsSymbol = function(symbol) {
return symbol.contains('fps');
};
Window_Options.prototype.booleanStatusText = function(value) {
return value ? 'ON' : 'OFF';
};
Window_Options.prototype.fpsStatusText = function(value) {
return value + 'Fps';
};
Window_Options.prototype.volumeStatusText = function(value) {
return value + '%';
};
Window_Options.prototype.processOk = function() {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value += this.volumeOffset();
if (value > 100) {
value = 0;
}
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else if(this.isBooleanSymbol(symbol)){
this.changeValue(symbol, !value);
} else if(this.isFpsSymbol(symbol)){
value += this.fpsOffset();
if (value > 60) {
value = 0;
}
value = value.clamp(15, 60);
this.changeFpsValue(symbol, value);
} else {
Window_Options._lastCommandSymbol = this.currentSymbol();
Window_Command.prototype.processOk.call(this);
}
};
Window_Options.prototype.cursorRight = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value += this.volumeOffset();
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else if(this.isFpsSymbol(symbol)){
value += this.fpsOffset();
value = value.clamp(15, 60);
this.changeFpsValue(symbol, value);
} else {
this.changeValue(symbol, true);
}
};
Window_Options.prototype.cursorLeft = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value -= this.volumeOffset();
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else if(this.isFpsSymbol(symbol)){
value -= this.fpsOffset();
value = value.clamp(15, 60);
this.changeFpsValue(symbol, value);
} else {
this.changeValue(symbol, false);
}
};
Window_Options.prototype.volumeOffset = function() {
return 20;
};
Window_Options.prototype.fpsOffset = function() {
return 15;
};
Window_Options.prototype.changeValue = function(symbol, value) {
var lastValue = this.getConfigValue(symbol);
if (lastValue !== value) {
this.setConfigValue(symbol, value);
this.redrawItem(this.findSymbol(symbol));
SoundManager.playCursor();
}
};
Window_Options.prototype.changeFpsValue = function(symbol, value) {
var lastValue = this.getConfigValue(symbol);
if (lastValue !== value) {
this.setFpsConfigValue(symbol, value);
this.redrawItem(this.findSymbol(symbol));
SoundManager.playCursor();
}
};
Window_Options.prototype.getConfigValue = function(symbol) {
return ConfigManager[symbol];
};
Window_Options.prototype.setConfigValue = function(symbol, volume) {
ConfigManager[symbol] = volume;
};
Window_Options.prototype.setFpsConfigValue = function(symbol, value) {
ConfigManager[symbol] = value;
}
【参考:オプション画面】