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

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

関連記事

no image

RPGツクールMVで防具を所持しているかをスクリプトから判定する

指定IDの防具を所持しているか $gameParty.hasItem( $dataArmors[1], true ); 第一引数の$dataArmors[1]の数値の部分は判定したい防具のI …

no image

RPGツクールMVのタイトル画面をスキップするプラグインYami_SkipTitleの使い方

こんにちは、今日はRPGツクールMVでゲーム起動後、タイトル画面をスキップし、即座にゲームのメイン画面に移行することができるプラグイン、Yami_SkipTitleの使い方についてまとめていきます。 …

no image

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

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

no image

マップ画面でダメージポップを表示できるRPGツクールMVプラグインCharacterPopupDamageの使い方

このプラグインを導入すると、上のgifのようにマップ画面でキャラクターにダメージポップを表示できます。 このプラグインはトリアコンタン様が制作されたものです。 確認環境 RPGツクールMV Versi …

no image

マップ画面に行動目標ウィンドウを表示するRPGツクールMVプラグインDestinationWindowの使い方

このプラグインを導入すると、上の画像のような行動目標を表示するウィンドウを追加することができます。 このプラグインはトリアコンタン様が制作されたものです。 確認環境 RPGツクールMV Version …