pure-full-lily/js/plugins/UpperPictureMZ.js
2025-09-16 10:12:44 -05:00

67 lines
2.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*:
* @target MZ
* @plugindesc ピクチャID3036をメッセージウィンドウよりも上に表示するが、フェードアウト時はフェードが優先されるように調整します。
* @author
*
* @help
* このプラグインは、ツクールMZにおいてピクチャID3036の画像を
* メッセージウィンドウよりも上に表示しますが、フェードアウト時はフェード用スプライトが上に表示されるようにします。
*
* 【使い方】
* 1. このファイルをプロジェクトの「js/plugins」フォルダに保存してください。
* 2. ツクールMZのプラグインマネージャーで本プラグインをONにしてください。
*
* 特にプラグインコマンドはありません。
*
* (MIT License)
*/
(function() {
'use strict';
// シーンの全ウィンドウ作成後に、上部ピクチャ用のコンテナを作成
const _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function() {
_Scene_Map_createAllWindows.call(this);
this.createUpperPictureContainer();
// 作成時にもフェードスプライトを最前面に移動
this.bringFadeSpriteToTop();
};
Scene_Map.prototype.createUpperPictureContainer = function() {
this._upperPictureContainer = new Sprite();
// ウィンドウレイヤーの後に追加することで、ウィンドウよりも上に表示されます
this.addChild(this._upperPictureContainer);
};
// フェード用スプライトをシーン内の最前面に移動する関数
Scene_Map.prototype.bringFadeSpriteToTop = function() {
if (this._fadeSprite) {
this.removeChild(this._fadeSprite);
this.addChild(this._fadeSprite);
}
};
// 毎フレーム更新時にフェードスプライトを最前面へ
const _Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
_Scene_Map_update.call(this);
this.bringFadeSpriteToTop();
};
// Sprite_Pictureの更新処理を上書きし、ID3036のピクチャを上部コンテナに移動
const _Sprite_Picture_update = Sprite_Picture.prototype.update;
Sprite_Picture.prototype.update = function() {
_Sprite_Picture_update.call(this);
if (this._pictureId >= 30 && this._pictureId <= 36) {
// すでに上部コンテナに所属していない場合、移動させる
if (SceneManager._scene && SceneManager._scene._upperPictureContainer && this.parent !== SceneManager._scene._upperPictureContainer) {
if (this.parent) {
this.parent.removeChild(this);
}
SceneManager._scene._upperPictureContainer.addChild(this);
}
}
};
})();