0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RPGツクールMZ プラグイン作成

Posted at

先駆者の方々がいくつも作成方法を発表してくださっていますが、
自分の理解を深めるための覚書として記事に残していこうと思います。

作成するプラグイン

今回は戦闘画面のモンスターの位置や、ステータスの位置を自分用にカスタマイズ出来るプラグインを作成しようと思います。

プラグインの作り方

プラグインを作ってみる より
既存メソッドの再定義 を読みますと、プロジェクト作成時に既に用意されている javascript のメソッドを再定義するコードを用意していけばプラグインを作成出来ることが分かります。

rmmz_objects.js
//-----------------------------------------------------------------------------
// Game_Picture
//
// The game object class for a picture.

function Game_Picture() {
    this.initialize(...arguments);
}

// do something

// prettier-ignore
Game_Picture.prototype.show = function(
    name, origin, x, y, scaleX, scaleY, opacity, blendMode
) {
// do something
};

↓ 再定義

TextPicture.js
const _Game_Picture_show = Game_Picture.prototype.show;
Game_Picture.prototype.show = function() {
  _Game_Picture_show.apply(this, arguments);
  // do something
};

戦闘画面の javascript ファイル探索

Battle でコード全体に検索をかけ、
再定義対象メソッドが定義されている javascript ファイルを探します。

rpg8.png

戦闘画面のステータス表示位置に関わる statusWindowRect を見つけましたので
試しにステータス表示位置を変更するプラグインを作成してみます。

独自プラグイン用意

プロジェクトフォルダの js/plugins 以下にステータス表示位置を変更する javascript ファイルを作成し、statusWindowRect を再定義するコードを記述します。

MyBattleStatus.js
(() => {

    Scene_Battle.prototype.statusWindowRect = function() {
        const extra = 10;
        const ww = Graphics.boxWidth - 192;
        const wh = this.windowAreaHeight() + extra;
        const wx = this.isRightInputMode() ? 0 : Graphics.boxWidth - ww;
        const wy = Graphics.boxHeight - wh + extra - 200; // y 座標変更
        return new Rectangle(wx, wy, ww, wh);
    };

})();

いざテスト!

戦闘テスト用のイベントを配置します。

rpg1.png
rpg2.png

ツクールのプラグイン管理から作成したプラグインを登録します。

rpg9.png

テストプレイで戦闘画面を確認します。

rpg10.png

:relaxed: 出来ました!

:writing_hand:今回はここまでです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?