个人记录保存
Project1论坛 小圈子 人才 不得学习技术
复制代码
//=================================================================================================
// Fun_NPC_Mess.js
//=================================================================================================
/*:
* @target MZ
* @plugindesc NPC头顶自动显示一段消息。
* @author 希夷先生
*
* @help
* 插件功能:NPC头顶自动显示一段消息
这是打开消息
const event = $gameMap.event(11);
const sprite = SceneManager._scene._spriteset._characterSprites
.find(s => s._character === event);
if (sprite) {
sprite.Fun_Mess_Show("我需要帮助!!!");
}
这是关闭消息
const event = $gameMap.event(11);
const sprite = SceneManager._scene._spriteset._characterSprites
.find(s => s._character === event);
if (sprite) {
sprite.Fun_Mess_Close();
}
*/
(() => {
Sprite_Character.prototype.Fun_Mess_Show = function(npc_text){
if (!this._npcTextWindow) {
let rect = new Rectangle(0, 0, 10, 10);
this._npcTextWindow = new _New_Window(rect);
this._npcTextWindow.paddingScale = 1;
this._npcTextWindow.npc_text = npc_text;
this._npcTextWindow.open();
this.addChild(this._npcTextWindow); // 挂在NPC身上
}
};
Sprite_Character.prototype.Fun_Mess_Close = function(){
if (this._npcTextWindow) {
this._npcTextWindow.close();
this.removeChild(this._npcTextWindow);
this._npcTextWindow = null;
}
};
})();
窗口源代码