Serge Event Name Plugin (FREE)
Hello guys, I'm here to bring you this plugin that shows the name of the event.
*You can configure the text size, position, and color.
More Plugins Here:
Serge Plugins
Serge Event Name (FREE)
Code: - //=============================================================================
- // SergeEventName.js
- //=============================================================================
- /*:
- * @target MZ
- * @plugindesc Displays names above events using note tags in RPG Maker MZ.
- * @author Serge
- * @url https://gamel001.itch.io/
- *
- * @param fontSize
- * @text Font Size
- * @desc Font size for the event names.
- * @type number
- * @default 20
- *
- * @param fontColor
- * @text Font Color
- * @desc Color for the event names. Use CSS color values.
- * @type string
- * @default #FFFFFF
- *
- * @param outlineColor
- * @text Outline Color
- * @desc Outline color for the event names. Use CSS color values.
- * @type string
- * @default #000000
- *
- * @param outlineWidth
- * @text Outline Width
- * @desc Width of the outline for the event names.
- * @type number
- * @default 4
- *
- * @param offsetX
- * @text Offset X
- * @desc Horizontal offset for the event name display from the center of the event.
- * @type number
- * @default 0
- *
- * @param offsetY
- * @text Offset Y
- * @desc Vertical offset for the event name display from the bottom of the event. Positive values move text up.
- * @type number
- * @default -40
- */
- (() => {
- const parameters = PluginManager.parameters('SergeEventName');
- const fontSize = parseInt(parameters['fontSize'], 10);
- const fontColor = String(parameters['fontColor']);
- const outlineColor = String(parameters['outlineColor']);
- const outlineWidth = parseInt(parameters['outlineWidth'], 10);
- const offsetX = parseInt(parameters['offsetX'], 10);
- const offsetY = parseInt(parameters['offsetY'], 10);
- class Sprite_EventName extends Sprite {
- constructor(event) {
- super();
- this._event = event;
- this.bitmap = new Bitmap(200, 48);
- this.bitmap.fontSize = fontSize;
- this.bitmap.textColor = fontColor;
- this.bitmap.outlineColor = outlineColor;
- this.bitmap.outlineWidth = outlineWidth;
- this.visible = false; // Initially hidden, will be shown after positioning
- }
- update() {
- super.update();
- if (this._event && this._event._erased) {
- this.parent && this.parent.removeChild(this);
- return;
- }
- this.updatePosition();
- this.refresh();
- }
- updatePosition() {
- if (SceneManager._scene instanceof Scene_Map && this._event) {
- const screenX = this._event.screenX();
- const screenY = this._event.screenY();
- this.x = screenX + offsetX - this.width / 2;
- // Applying offsetY so positive values move the name up
- this.y = screenY - offsetY - this.height - $gameMap.tileHeight();
- this.z = 9;
- this.visible = true;
- }
- }
- refresh() {
- const nameMatch = /<EventName:(.+?)>/.exec(this._event.event().note);
- if (nameMatch) {
- this.bitmap.clear();
- const eventName = nameMatch[1];
- this.bitmap.drawText(eventName, 0, 0, 200, 48, "center");
- }
- }
- }
- const _Scene_Map_start = Scene_Map.prototype.start;
- Scene_Map.prototype.start = function() {
- _Scene_Map_start.call(this);
- this.createEventNameSprites();
- };
- Scene_Map.prototype.createEventNameSprites = function() {
- const events = $gameMap.events();
- events.forEach(event => {
- const nameMatch = /<EventName:(.+?)>/.exec(event.event().note);
- if (nameMatch && !event._eventNameSprite) {
- const eventNameSprite = new Sprite_EventName(event);
- this._spriteset._tilemap.addChild(eventNameSprite);
- event._eventNameSprite = eventNameSprite;
- eventNameSprite.refresh();
- }
- });
- };
- })();
复制代码
本贴来自国际rpgmaker官方论坛作者:gamel001处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址: https://forums.rpgmakerweb.com/threads/free-plugin-event-name.167286/ |