3テラバイト

プログラム関連備忘録サイト。主にゲーム。

RPGツクールMV

RPGツクールMV – 自作プラグインでアイコンを表示する

投稿日:2020年5月17日 更新日:

こんにちは、今日はRPGツクールMVの自作プラグインで独自の画面にアイコンを表示する方法についてまとめていきます。

確認環境

RPGツクールMV Version 1.6.2

アイコンを表示する関数

Window_Baseクラスに定義されているdrawIcon関数を使用します。
Window_Baseを継承したクラス内で以下の関数を使用して表示することができます。
第一引数にアイコン番号、第二引数にX座標、第三引数にY座標を設定します。

this.drawIcon(97, 0, 0);
this.drawIcon(128, Window_Base._iconWidth, 0);
this.drawIcon(137, 0, Window_Base._iconHeight);

サンプル

プラグインコマンド「TestScene」でウィンドウを一つ表示する独自のシーンを呼び出します。
そのウィンドウ内でアイコンを表示するサンプルです。

(function() {
    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        switch(command){
            case 'TestScene':
                SceneManager.push(Scene_Test);
            break;
        }
    };

    //--------------------------------------------------
    // Name : Scene_Test
    // Desc : テストシーンクラス
    //--------------------------------------------------
    function Scene_Test() {
        this.initialize.apply(this, arguments);
    }

    Scene_Test.prototype = Object.create(Scene_Base.prototype);
    Scene_Test.prototype.constructor = Scene_Test;

    Scene_Test.prototype.initialize = function() {
        Scene_Base.prototype.initialize.call(this);
    };

    Scene_Test.prototype.create = function() {
        Scene_Base.prototype.create.call(this);
        this.createBackground();
        this.createWindowLayer();

        this._testWindow = new Window_Test(0, 0, Graphics.boxWidth, Graphics.boxHeight);
        this.addWindow(this._testWindow);

        this._testWindow.setBackgroundType(0);
    };

    Scene_Test.prototype.update = function() {
        Scene_Base.prototype.update.call(this);

        if (Input.isRepeated('cancel')) {
            this.popScene();
        }
    };

    Scene_Test.prototype.createBackground = function() {
        this._backgroundSprite = new Sprite();
        this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
        this.addChild(this._backgroundSprite);
    };

    //--------------------------------------------------
    // Name : Window_Test
    // Desc : テストウィンドウクラス
    //--------------------------------------------------
    function Window_Test() {
        this.initialize.apply(this, arguments);
    }

    Window_Test.prototype = Object.create(Window_Base.prototype);
    Window_Test.prototype.constructor = Window_Test;

    Window_Test.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
    };

    Window_Test.prototype.update = function() {
        Window_Base.prototype.update.call(this);
		this.refresh();
    };

    Window_Test.prototype.refresh = function() {
        this.contents.clear();
        this.drawIcon(97, 0, 0);
        this.drawIcon(128, Window_Base._iconWidth, 0);
        this.drawIcon(137, 0, Window_Base._iconHeight);
    };

})();

-RPGツクールMV


comment

メールアドレスが公開されることはありません。

関連記事

no image

RPGツクールMVで選択肢に制限時間を設定できるプラグインChoiceListWithTimeLimitの使い方

このプラグインはこま様が制作されたプラグインです。 ダウンロード 以下のページにプラグイン本体へのリンクが置かれています。ChoiceListWithTimeLimit.js(時間制限付き選択肢)のD …

no image

RPGツクールMVでピクチャをボタン化するプラグインPictureCallCommonの使い方

本プラグインを有効化すると、プラグインコマンドで任意のピクチャをクリック時に指定したコモンイベントを呼び出すようにすることができます。 このプラグインはトリアコンタン様が制作されたものです。 確認環境 …

no image

RPGツクールMVでセルフスイッチの操作をスクリプトから行う

イベントコマンドの1ページ目、ゲーム進行 > セルフスイッチの操作…と同様の操作を、イベントコマンドの3ページ目、上級 > スクリプトから行う方法です。 スクリプトコード 以下のコードでセルフスイッチ …

no image

RPGツクールMV – スクリプトでスイッチによる可変の選択肢を作る

イベントコマンドの選択肢の表示で最大6個の選択肢を表示できますが、選択肢の内容をスイッチ等の要素から可変にすることができません。 特定のスイッチがONの場合に選択肢を増やす場合は、別の選択肢を用意し条 …

no image

RPGツクールMVでゲーム内時間を追加するプラグインChronusの使い方

本プラグインを導入すると、上のgifのように画面左上に時計が表示され、時間によって画面の色調を変更することで時間の変化を表現でき、天候も時間により自動で変化します。 このプラグインはトリアコンタン様が …