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