スクリプト初心者です。
とんちんかんなことを言ってたらすみません。
・やりたいこと
戦闘の終わり(経験値等の処理が終了してからScene_Battleが終了するまでの間)に選択肢ウィンドウを表示させたいです。
・試した方法
BattleManager.processVictoryに処理を追加して実現しようと思ったのですが、BattleManagerにはWindowレイヤーが無いので、Scene_Battleに目的のウィンドウに関する処理を追加しました。
しかし、それをprocessVictory内で画面に表示させる方法がわからず、断念しました。
Scene_Battleのみをいじる方法でも、Scene_Battleに追加したウィンドウをprocessVictory内で表示させる方法でも構いませんので、やりたいことを実現させる方法がありましたら、ご教示ください。
【解決済み】戦闘終了時に選択肢ウィンドウを表示する方法
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
Toshico さんが書きました:スクリプト初心者です。
とんちんかんなことを言ってたらすみません。
・やりたいこと
戦闘の終わり(経験値等の処理が終了してからScene_Battleが終了するまでの間)に選択肢ウィンドウを表示させたいです。
・試した方法
BattleManager.processVictoryに処理を追加して実現しようと思ったのですが、BattleManagerにはWindowレイヤーが無いので、Scene_Battleに目的のウィンドウに関する処理を追加しました。
しかし、それをprocessVictory内で画面に表示させる方法がわからず、断念しました。
Scene_Battleのみをいじる方法でも、Scene_Battleに追加したウィンドウをprocessVictory内で表示させる方法でも構いませんので、やりたいことを実現させる方法がありましたら、ご教示ください。
とりあえず、書いたプラグインをここにアップしてみてください。
「ウィンドウが表示されない」は原因が複数あるので、中身を見ないと分かりません。
また、選択肢を表示とありますが、どのような内容を表示するのでしょうか?
現在、プラグイン依頼はお休み中です。
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
コードはこんな感じです。
よろしくお願いします。
よろしくお願いします。
コード: 全て選択
(function () {
'use strict';
BattleManager.processVictory = function() {
$gameParty.removeBattleStates();
$gameParty.performVictory();
this.playVictoryMe();
this.replayBgmAndBgs();
this.makeRewards();
this.displayVictoryMessage();
this.displayRewards();
this.gainRewards();
//このタイミングで選択肢を追加したい。戦闘シーンが終わる前ならここじゃなくてもいい。
this.displayEndCommand();
this.endBattle(0);
};
BattleManager.displayEndCommand = function(){
//ここで選択肢ウィンドウを開きたい。
}
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow;
_Scene_Battle_createAllWindows.call(this);
}
Scene_Battle.prototype.createEndWindow = function(){
this._endWindow = new Window_endCommand(560,300);
this._endWindow.setHandler("yes",this.onYes.bind(this));
this._endWindow.setHandler("no",this.onNo.bind(this));
this._endWindow.setHandler("cancel",this.onNo.bind(this));
this.addWindow(_endWindow);
}
Scene_Battle.prototype.onYes = function(){
//はいの時の処理。
}
Scene_Battle.prototype.onNo = function(){
//いいえの時の処理。
}
//選択肢ウィンドウを用意。
function Window_endCommand(){
this.initialize.apply(this,arguments);
}
Window_endCommand.prototype = Object.create(Window_Command.prototype);
Window_endCommand.prototype.constructor = Window_endCommand;
Window_endCommand.prototype.makeCommandList = function(){
this.addCommand("はい","yes",true);
this.addCommand("いいえ","no",true);
}
})();
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
(function () {
'use strict';
BattleManager.processVictory = function() {
$gameParty.removeBattleStates();
$gameParty.performVictory();
this.playVictoryMe();
this.replayBgmAndBgs();
this.makeRewards();
this.displayVictoryMessage();
this.displayRewards();
this.gainRewards();
//このタイミングで選択肢を追加したい。戦闘シーンが終わる前ならここじゃなくてもいい。
this.displayEndCommand();
this.endBattle(0);
};
BattleManager.displayEndCommand = function(){
//ここで選択肢ウィンドウを開きたい。
this._endWindow.show();
}
BattleManager.setEndCommand = function(endWindow){
this._endWindow = endWindow;
}
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow;
_Scene_Battle_createAllWindows.call(this);
}
Scene_Battle.prototype.createEndWindow = function(){
this._endWindow = new Window_endCommand(560,300);
this._endWindow.setHandler("yes",this.onYes.bind(this));
this._endWindow.setHandler("no",this.onNo.bind(this));
this._endWindow.setHandler("cancel",this.onNo.bind(this));
this._endWindow.hide();
this.addWindow(_endWindow);
BattleManager.setEndCommand(this._endWindow);
}
Scene_Battle.prototype.onYes = function(){
//はいの時の処理。
}
Scene_Battle.prototype.onNo = function(){
//いいえの時の処理。
}
//選択肢ウィンドウを用意。
function Window_endCommand(){
this.initialize.apply(this,arguments);
}
Window_endCommand.prototype = Object.create(Window_Command.prototype);
Window_endCommand.prototype.constructor = Window_endCommand;
Window_endCommand.prototype.makeCommandList = function(){
this.addCommand("はい","yes",true);
this.addCommand("いいえ","no",true);
}
})();
あと、自分で考えてこういう書き方もしてみたのですが、(太字が追加分)
Cannot read property 'show' of undefined とエラーが出てダメでした。
'use strict';
BattleManager.processVictory = function() {
$gameParty.removeBattleStates();
$gameParty.performVictory();
this.playVictoryMe();
this.replayBgmAndBgs();
this.makeRewards();
this.displayVictoryMessage();
this.displayRewards();
this.gainRewards();
//このタイミングで選択肢を追加したい。戦闘シーンが終わる前ならここじゃなくてもいい。
this.displayEndCommand();
this.endBattle(0);
};
BattleManager.displayEndCommand = function(){
//ここで選択肢ウィンドウを開きたい。
this._endWindow.show();
}
BattleManager.setEndCommand = function(endWindow){
this._endWindow = endWindow;
}
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow;
_Scene_Battle_createAllWindows.call(this);
}
Scene_Battle.prototype.createEndWindow = function(){
this._endWindow = new Window_endCommand(560,300);
this._endWindow.setHandler("yes",this.onYes.bind(this));
this._endWindow.setHandler("no",this.onNo.bind(this));
this._endWindow.setHandler("cancel",this.onNo.bind(this));
this._endWindow.hide();
this.addWindow(_endWindow);
BattleManager.setEndCommand(this._endWindow);
}
Scene_Battle.prototype.onYes = function(){
//はいの時の処理。
}
Scene_Battle.prototype.onNo = function(){
//いいえの時の処理。
}
//選択肢ウィンドウを用意。
function Window_endCommand(){
this.initialize.apply(this,arguments);
}
Window_endCommand.prototype = Object.create(Window_Command.prototype);
Window_endCommand.prototype.constructor = Window_endCommand;
Window_endCommand.prototype.makeCommandList = function(){
this.addCommand("はい","yes",true);
this.addCommand("いいえ","no",true);
}
})();
あと、自分で考えてこういう書き方もしてみたのですが、(太字が追加分)
Cannot read property 'show' of undefined とエラーが出てダメでした。
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
Toshico様
this.createEndWindow;は
this.createEndWindow();にした方がよいと思います。
this.createEndWindow;は
this.createEndWindow();にした方がよいと思います。
RPGで笑顔を・・・
ツイッター(ツクラーの巣窟)(閲覧は自己責任でお願いします)
https://twitter.com/mattuup
github
https://github.com/mattuup/RPGMakerMZ
ツイッター(ツクラーの巣窟)(閲覧は自己責任でお願いします)
https://twitter.com/mattuup
github
https://github.com/mattuup/RPGMakerMZ
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
ご指摘ありがとうございます。
this.addWindow(_endWindow);
の引数にthis.が抜けてたところも気づいて直したらウィンドウは一応、一部表示されたのですが、思ったような表示になりませんでした。
↑のように表示され、また戦闘開始時の「敵グループが出現。」というメッセージのところで決定キーを押す回数が1回増えていました。
コードは↓です。
this.addWindow(_endWindow);
の引数にthis.が抜けてたところも気づいて直したらウィンドウは一応、一部表示されたのですが、思ったような表示になりませんでした。
↑のように表示され、また戦闘開始時の「敵グループが出現。」というメッセージのところで決定キーを押す回数が1回増えていました。
コードは↓です。
コード: 全て選択
(function () {
'use strict';
BattleManager.processVictory = function() {
$gameParty.removeBattleStates();
$gameParty.performVictory();
this.playVictoryMe();
this.replayBgmAndBgs();
this.makeRewards();
this.displayVictoryMessage();
this.displayRewards();
this.gainRewards();
//このタイミングで選択肢を追加したい。戦闘シーンが終わる前ならここじゃなくてもいい。
this.displayEndCommand();
this.endBattle(0);
};
BattleManager.displayEndCommand = function(){
//ここで選択肢ウィンドウを開きたい。
this._endWindow.show();
this._endWindow.active();
}
BattleManager.setEndCommand = function(endWindow){
this._endWindow = endWindow;
}
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow();
_Scene_Battle_createAllWindows.call(this);
}
Scene_Battle.prototype.createEndWindow = function(){
this._endWindow = new Window_endCommand(560,300);
this._endWindow.setHandler("yes",this.onYes.bind(this));
this._endWindow.setHandler("no",this.onNo.bind(this));
this._endWindow.setHandler("cancel",this.onNo.bind(this));
this._endWindow.hide();
this.addWindow(this._endWindow);
BattleManager.setEndCommand(this._endWindow);
}
Scene_Battle.prototype.onYes = function(){
//はいの時の処理。
}
Scene_Battle.prototype.onNo = function(){
//いいえの時の処理。
}
//選択肢ウィンドウを用意。
function Window_endCommand(){
this.initialize.apply(this,arguments);
}
Window_endCommand.prototype = Object.create(Window_Command.prototype);
Window_endCommand.prototype.constructor = Window_endCommand;
Window_endCommand.prototype.makeCommandList = function(){
this.addCommand("はい","yes",true);
this.addCommand("いいえ","no",true);
}
})();
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
hide()をClose()に、show()をopen()に変えたら、戦闘開始時に選択肢がアクティブになってしまうのは回避できましたが、やはり、戦闘終了後の画面では↑の画像のように半端な表示になってしまうようです。
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
こんにちは。
恐らく選択肢ウィンドウの生成順番が問題かと。
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow;//これは、↓の処理の後がよい。
_Scene_Battle_createAllWindows.call(this);
}
このままだと、ログウィンドウよりも下になるため、
添付写真のようにログウィンドウに隠れてしまいます。
恐らく選択肢ウィンドウの生成順番が問題かと。
//Scene_Battleに選択肢を追加。
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function(){
this.createEndWindow;//これは、↓の処理の後がよい。
_Scene_Battle_createAllWindows.call(this);
}
このままだと、ログウィンドウよりも下になるため、
添付写真のようにログウィンドウに隠れてしまいます。
---------------------------------------------------------------------------------------------------
プラグイン置き場(GitHub)
https://github.com/futokoro/RPGMaker/blob/master/README.md
検討中の内容は上記リンク先の「対応するかもしれないプラグインのメモ」を参照してください。
プラグイン置き場(GitHub)
https://github.com/futokoro/RPGMaker/blob/master/README.md
検討中の内容は上記リンク先の「対応するかもしれないプラグインのメモ」を参照してください。
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
this._endWindow.active();のところって
this._endWindow.activate();でいいですよね。
this._endWindow.activate();でいいですよね。
RPGで笑顔を・・・
ツイッター(ツクラーの巣窟)(閲覧は自己責任でお願いします)
https://twitter.com/mattuup
github
https://github.com/mattuup/RPGMakerMZ
ツイッター(ツクラーの巣窟)(閲覧は自己責任でお願いします)
https://twitter.com/mattuup
github
https://github.com/mattuup/RPGMakerMZ
Re: 戦闘終了時に選択肢ウィンドウを表示する方法
>>フトコロさん、まっつUPさん
ご指摘の通りにしたところ、無事、思ってた通りの動きになりました。
みなさん、回答ありがとうございました。
ご指摘の通りにしたところ、無事、思ってた通りの動きになりました。
みなさん、回答ありがとうございました。