查看: 3858|回复: 3

[原创发布] MiniLab在事件顶部显示一个文字

[复制链接]
梦石
0
星屑
4122
在线时间
302 小时
注册时间
2019-4-23
回帖
185
发表于 2020-8-26 16:04:05 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 q3226257 于 2020-9-7 14:42 编辑

1598428898(1).jpg

MZ新出,写个超级简单的插件来蹭下热度~~~~
效果如图,在事件栏备注一下名字就可以了:
  1. <name:破坏神>
复制代码


特别注意,改插件依赖于 MZ 自带的插件:PluginBaseFunction


修复了文字显示背景未清除的Bug!!!

  1. /*:
  2. *
  3. *
  4. * @plugindesc headName
  5. * @author lh
  6. * @date  14:42
  7. * @target MZ
  8. * @base PluginBaseFunction
  9. *
  10. * @param front
  11. * @text 字体大小
  12. * @desc 绘制顶部文字的大小
  13. * @default 18
  14. * @type number
  15. *
  16. * @param width
  17. * @text 宽度
  18. * @desc 当名字比较长显示不下可以调大该值
  19. * @default 64
  20. * @type number
  21. *
  22. * @param height
  23. * @text 高度
  24. * @desc 默认是居中的,所以会影响padding值
  25. * @default 18
  26. * @type number
  27. *
  28. * @param bgColor
  29. * @text 背景颜色
  30. * @desc 背景颜色
  31. * @default rgba(0,0,0,0.5)
  32. * @type color
  33. *
  34. * @help
  35. * 事件栏备注:
  36. *  <name:破坏神,2>
  37. *
  38. *
  39. *
  40. */
  41. const solve_HeadName = PluginManager.parameters('Solve_SimpleHeadName')
  42. solve_HeadName.width =parseInt(solve_HeadName.width)
  43. solve_HeadName.height =parseInt(solve_HeadName.height)
  44. function Sprite_HeadName() {
  45.     this.initialize(...arguments);
  46. }

  47. Sprite_HeadName.prototype = Object.create(Sprite.prototype);
  48. Sprite_HeadName.prototype.constructor = Sprite_HeadName;

  49. Sprite_HeadName.prototype.initialize = function (deploy) {
  50.     Sprite.prototype.initialize.call(this);
  51.     this._deploy = deploy;
  52.     this.bitmap = new Bitmap(solve_HeadName.width, solve_HeadName.height)
  53. };

  54. Sprite_HeadName.prototype.update = function () {
  55.     Sprite.prototype.update.call(this);

  56.     this.x = this._deploy.x - (solve_HeadName.width) / 2
  57.     this.y = this._deploy.y - solve_HeadName.height - this._deploy.height
  58.     this.z = this._deploy.z + 1

  59.     this.opacity = this._deploy.opacity
  60.     this.blendMode = this._deploy.blendMode
  61.     this._bushDepth = this._deploy._bushDepth

  62.     this.visible = this._deploy.visible;

  63.     if (this.bitmap._headName === this.headName()) return
  64.     this.bitmap.outlineWidth = 0
  65.     this.bitmap.fontSize = solve_HeadName.front
  66.     this.bitmap.clear()
  67.     this.bitmap._headName = this.headName()
  68.     let [name,color] =this.bitmap._headName.split(',')
  69.     this.bitmap.textColor=ColorManager.textColor( parseInt(color)||0)
  70.     // this.bitmap.clearRect(0, 0, solve_HeadName.width, solve_HeadName.height);
  71.     this.bitmap.fillRoundRect(0,0, solve_HeadName.width, solve_HeadName.height,5,1,solve_HeadName.bgColor)
  72.     this.bitmap.drawText(name, 0, 0, solve_HeadName.width, solve_HeadName.height, 'center')
  73. }


  74. Sprite_HeadName.prototype.headName = function () {
  75.     let character = this._deploy._character;
  76.     if (character && character.findMeta) {
  77.         return character.findMeta("name") || ''
  78.     }
  79.     return '';
  80. }

  81. solve_HeadName.Sprite_Character_initialize = Sprite_Character.prototype.initialize
  82. Sprite_Character.prototype.initialize = function (character) {
  83.     solve_HeadName.Sprite_Character_initialize.call(this, character);
  84.     if (character && character.findMeta && character.findMeta("name")) {
  85.         this._headSprite = new Sprite_HeadName(this)
  86.     }
  87. };

  88. solve_HeadName.Sprite_Character_update = Sprite_Character.prototype.update
  89. Sprite_Character.prototype.update = function () {
  90.     solve_HeadName.Sprite_Character_update.call(this);
  91.     if (this._headSprite) {
  92.         this.parent.addChild(this._headSprite)
  93.         this._headSprite = undefined;
  94.     }
  95. };
复制代码

Solve_SimpleHeadName.zip

1.1 KB, 下载次数: 59

售价: 1 星屑  [记录]

评分

参与人数 2赞 +2 收起 理由
migualmi + 1 我很赞同
白嫩白嫩的 + 1 精品文章

查看全部评分

梦石
0
星屑
58
在线时间
7 小时
注册时间
2020-8-23
回帖
5
发表于 2020-8-29 23:52:54 | 显示全部楼层
非常感谢!很有用!
回复

使用道具 举报

梦石
0
星屑
4122
在线时间
302 小时
注册时间
2019-4-23
回帖
185
 楼主| 发表于 2020-9-7 14:42:39 | 显示全部楼层
加了个背景  加了颜色配置
回复

使用道具 举报

梦石
0
星屑
131
在线时间
20 小时
注册时间
2015-11-14
回帖
5
发表于 2020-9-8 21:10:58 | 显示全部楼层
太感谢大佬啦!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部