rpgmaker玩家命名--RPGMakerMZ游戏引擎 地图角色顶部显示称号 - 个人需求 发布保存 以防以后忘记
个人需求 发布保存 以防以后忘记
直接上代码
(() => {
const _Sprite_Character_prototype_initialize = Sprite_Character.prototype.initialize;
Sprite_Character.prototype.initialize = function(character) {
_Sprite_Character_prototype_initialize.call(this, character);
// 仅给玩家主角添加标题窗口
if (this._character instanceof Game_Player) {
this.createTitle();
}
};
Sprite_Character.prototype.createTitle = function() {
this.title_text = "无双英雄";
this.title_bitmap = new Bitmap(1, 48);
this.title_bitmap.fontFace = $gameSystem.mainFontFace();
this.title_bitmap.fontSize = $gameSystem.mainFontSize();
this.bitmap_width = this.title_bitmap.measureTextWidth(this.title_text);
this.title_bitmap.resize(this.bitmap_width, 48);
this.title_bitmap.textColor = ColorManager.normalColor();
this.title_bitmap.outlineColor = ColorManager.outlineColor();
this.title_bitmap.smooth = true;
this.title_bitmap.drawText( this.title_text, 0, 0, this.bitmap_width, 48, "center"); 拼多多帮助力入口
this.title_Sprite = new Sprite( this.title_bitmap );
this.title_Sprite.move( -(this.bitmap_width / 2), -90);
this.addChild(this.title_Sprite);
};
})();
上面的是全部功能代码 粘贴复制即可使用 根据需求修改字符串
判断是否是角色 如何当前是角色的话 初始化 Game_Player 是玩家角色 Game_Event是地图NPC 这是不同的需要判断
if (this._character instanceof Game_Player) {
this.createTitle();
}
接下来代码很普通 创建一个位图 一个精灵 设置显示坐标 绑定到角色上 就可以了
结尾总结
请Project1论坛的小圈子 离开