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でアイテムメニューのカテゴリを非表示にできるプラグインEquipmentAcrobatの使い方

このプラグインはまっつUP様が制作されたプラグインです。 確認環境 RPGツクールMV Version 1.6.2EquipmentAcrobat ver1.03 ダウンロード 以下のURLに配置され …

no image

RPGツクールMVの用語をスクリプトで変更する

こんにちは、今日は データベース > 用語 から設定できるゲーム内各所で使用される用語について、ゲーム中で動的に変更する方法についてまとめていきます。 本記事ではイベントコマンドのスクリプトを使 …

no image

RPGツクールMVでアクターのバトルコマンドから直接スキルを使用するプラグインHIME_BattleCommandUseSkillの使い方

こんにちは、今日はRPGツクールMVで、アクターのバトルコマンドから直接スキルを使用することができるプラグインHIME_BattleCommandUseSkillの使い方についてまとめていきます。 確 …

no image

RPGツクールMV – “Made with MV”のスプラッシュ画面表示をカスタマイズするプラグインMadeWithMvの使い方

こんにちは、今日はRPGツクールMVでタイトル画面の前に表示される”Made with MV”のスプラッシュ画面表示をカスタマイズするプラグインのMadeWithMvの使い方に …

no image

RPGツクールMVで獲得経験値をパーティメンバーで割るプラグインHIME_BattleExpDistributionの使い方

このプラグインを導入すると、戦闘で獲得した経験値を生存しているパーティメンバーで割った値が加算されるようになります。 このプラグインはHimeWorks様が制作されたものです。 確認環境 RPGツクー …