RPGMZ NPC头顶自动显示一段消息

个人记录保存

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;
        }
	};
	
})();

窗口源代码

相关推荐
半个落月4 分钟前
从零梳理 React Router:路由、懒加载、嵌套页面与登录鉴权
前端·react.js
tedcloud12330 分钟前
Impeccable 部署指南:开源前端设计工具 Linux 环境搭建实践
linux·运维·服务器·前端·人工智能·开源
默_笙39 分钟前
🚩 React + TypeScript 的 Props 通信,我从"把事件对象传给父组件"进化到了"只传值"
前端·javascript
渣波43 分钟前
赋予 React “多线程”:Hooks + Web Worker 并发计算架构深度解析
前端·javascript
光影少年1 小时前
Codex 斜杠指令体系与业务场景调度实战
前端·react.js·reactivex
90后的晨仔1 小时前
uni-app中如何跳转?
前端
Y3815326622 小时前
SERP API 请求体 Gzip 压缩优化实战:大数据量降带宽 80%
开发语言·前端·php
踩着两条虫3 小时前
VTJ.PRO AI Agent 技术白皮书
前端·vue.js·低代码
子兮曰3 小时前
解剖 Claude Code:从入口架构逆向工程看 AI 编程工具的信任边界设计
前端·后端·claude
先吃饱再说3 小时前
层层传递太“痛”了:useContext 给 React 组件装了个“无线遥控器”
前端·react.js·前端框架