ツクールMVにて、右上に現在のゲーム内時間を常に表示するウィンドウを作成したいと思い、kotonoha*様のInfoWindow.jsを参考にさせていただき、さらに他のプラグイン製作者様の作成したプラグインを参考に以下のようなテスト用プラグインを作成いたしました。スイッチや変数は以下のように使用されております。
フィールド上で特定のイベント(採取や戦闘など)を読み込んだ時に、時間が経過する仕様なので、常に時間は表示するようになっています。
スイッチ#0001 : true=表示 false=非表示
変数 #0005 : 日にちを表す変数
変数 #0006 : 時間(分)を表す変数
tomoaky様が作成した「TMMapHpGauge.js」も作成中のゲームで併用しているので、同様の動作を行うようなウィンドウが作成したいです。
(・メニューを起動時、ウィンドウが瞬間消去され、メニューを閉じた後に瞬間表示される。
・バトル開始時、ウィンドウが瞬間消去され、終了後に瞬間表示される。)
・プラグインコマンドにより、ウィンドウが緩やかに開閉する。)
しかし、私はjsの記述に慣れていないため、思うようなプラグインが作成できませんでした。
上記カッコ内の仕様で動くようなウィンドウの作成方法を教えていただけないでしょうか?
この以下のプラグインはスイッチにより表示のON,OFFを変更していますが、可能であればプラグインコマンドにより開閉させられるようにしたいです。
コード: 全て選択
// TimeWindow.js
(function() {
var Scene_map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
Scene_map_start.call(this);
this._TimeWindow = new TimeWindow();
this.addWindow(this._TimeWindow);
};
var _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_Scene_Map_update.call(this);
this._TimeWindow.loadText();
};
function TimeWindow() {
this.initialize.apply(this, arguments);
}
TimeWindow.prototype = Object.create(Window_Base.prototype);
TimeWindow.prototype.constructor = TimeWindow;
TimeWindow.prototype.initialize = function() {
if ($gameSwitches.value(1) == true){
Window_Base.prototype.initialize.call(this, 626, 10, 180, 108);
this.openness = 255;
this.contents.clear();
this.drawText($gameVariables.value(5) + "日目", 1, 1);
var hour = Math.floor($gameVariables.value(6)/60);
var min = $gameVariables.value(6)%60;
this.drawText(hour + " 時 " + min + " 分",0,this.lineHeight());
} else {
Window_Base.prototype.initialize.call(this, 626, 10, 180, 108);
this.openness = 0;
this.contents.clear();
}
};
TimeWindow.prototype.loadText = function() {
if ($gameSwitches.value(1) == true){
this.opacity = 255;
this.contents.clear();
this.drawText($gameVariables.value(5) + "日目", 1, 1);
var hour = Math.floor($gameVariables.value(6)/60);
var min = $gameVariables.value(6)%60;
this.drawText(hour + " 時 " + min + " 分",0,this.lineHeight());
this.opacity = 255;
} else {
this.opacity = 0;
this.contents.clear();
this.opacity = 0;
}
};
TimeWindow.prototype.standardFontSize = function() {
return 24;
};
})();