じ☆ve冰风 发表于 2024-3-2 07:12:09

事件名称--NPC名字显示(搬运修改)插件

事件名称--NPC名字显示插件
前几天在论坛搜索的一个这样的插件 原本是打算用yep的,但是最终显示出来的文字效果有点不理想
后面找到了这个简短的插件 感觉很不错 就决定使用这个了 为了实现一些自己想要的效果 稍微地修改了些 搬运上来

1、新增了字体颜色的自定义设置
2、优化了文字与事件同步显示

脚本初学菜鸟 若有哪里不对的 还请各位大佬们指正

JAVASCRIPT 代码下载

/*:
* @plugindesc Namepop Ver 1.03 NPC名称显示
* @author Morpho(dongdongDJH)
*
* @help
* 在地图事件注释栏内填入 NAMEPOP|高度修正值|字体Size|字体颜色;
* 高度修正值单位为1格,不填默认为1,字体大小不填默认为18;
* 例:NAMEPOP|1|18|#00FF00 ; NAMEPOP||20 ;
* 注:一定要用‘|’分隔高度修正值和字体Size;
* 若要调整描边 请直接在下方代码中调整 (ps:0.8是颜色的透明度,0-1)
*/
(function(){
      _Sprite_Character_prototype_initialize = Sprite_Character.prototype.initialize;
      Sprite_Character.prototype.initialize = function(character){
                _Sprite_Character_prototype_initialize.call(this, character);
                this._tempCharacter = character;
                if(character instanceof Game_Event){
                        if(character.event().note.match("NAMEPOP") != null){
                              var notetext = character.event().note.split("|");
                              this._namepopY = Number(notetext) || 1;
                              this._fontSize = Number(notetext) || 18;
                              this._BYcolor=notetext || "#FFFFFF";
                              this.createNamepopSet();
                        }
                }
      };

      Sprite_Character.prototype.createNamepopSet = function(){
                var h = this._fontSize;
                this._namepopSprite = new Sprite();
                this._namepopSprite.bitmap = new Bitmap(h * 10, h);
                this._namepopSprite.bitmap.fontSize = h;
                this._namepopSprite.bitmap.outlineColor = "rgba(0, 0, 0, 0.8)"//描边颜色
                this._namepopSprite.bitmap.outlineWidth = 4;//字体描边
                this._namepopSprite.bitmap.textColor = this._BYcolor;//字体颜色
                this._namepopSprite.bitmap.drawText(this._tempCharacter.event().name, 0, 0, h * 10, h, 'center');
                this._namepopSprite.anchor.x = 0.5;
                this._namepopSprite.anchor.y = 1;
                this._namepopSprite.y = this.y - this._namepopY * 48;
                this.addChild(this._namepopSprite);
      };

// ---- 新增跟随事件显示 ----
      _Sprite_Character_prototype_setCharacterBitmap = Sprite_Character.prototype.setCharacterBitmap;
      Sprite_Character.prototype.setCharacterBitmap = function(){
                _Sprite_Character_prototype_setCharacterBitmap.call(this);
      if(this._tempCharacter instanceof Game_Event){
                        this._BYconditions = this._tempCharacter.findProperPageIndex();
                        if(this._BYconditions >= 0 &&this._namepopSprite){
                              this._namepopSprite.visible = true;
                        }elseif(this._namepopSprite){
                              this._namepopSprite.visible = false;
                        }

                }
      };

}());



             本帖来自P1论坛作者wr282828,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=411060若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: 事件名称--NPC名字显示(搬运修改)插件