设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 6107|回复: 5
打印 上一主题 下一主题

[原创发布] Namepop-增强版(文字颜色)

[复制链接]

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
跳转到指定楼层
1
发表于 2016-1-16 17:01:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 salvareless 于 2016-1-16 17:04 编辑

本插件基于dongdongdjh的同名脚本Namepop改写而成。原插件地址:https://rpg.blue/thread-385850-1-2.html
这个插件本来是我自己有这方面的需要,所以参考MOG_EventText.js,改写而成。
具体用法插件里面有写,贴出来是希望可以分享给有相同需要的玩家,希望大家喜欢。
  1. /*:
  2. * @plugindesc Namepop Ver 1.03
  3. * @author Morpho(dongdongDJH)--这是原作者
  4. * @由salvareless扩充为可以设置文字显示的颜色


  5. * @help
  6. * 在地图事件注释栏内填入<pop:显示名称(不可缺省),颜色(以#000000表示,不可缺省),字体大小(正数,可以缺省),高度修正(任意数字,可以缺省)>;
  7. * 高度修正值单位为1.1格,字体大小默认为12;
  8. * 例:<pop:测试NPC,#ff0000,14,1.1>
  9. * 例:<pop:测试二,#ff0000,,>

  10. */

  11. (function() {
  12.         _Sprite_Character_prototype_initialize = Sprite_Character.prototype.initialize;
  13.         Sprite_Character.prototype.initialize = function(character) {
  14.                 _Sprite_Character_prototype_initialize.call(this, character);
  15.                 this._tempCharacter = character;
  16.                 if (character instanceof Game_Event) {
  17.          var datas = character.event().note.match(/\<pop:.*,#[0-9a-f]{6},[.0-9]*,[-.0-9]*\>/i);
  18.                         if (datas != null) {
  19.                     datas = datas[0].slice(5,datas[0].length-1).split(',');
  20.                                         var nameh = datas[2] || 12;
  21.                                         var namey = datas[3] || 1.1;
  22.                                 this.createNamepopSet(decodeURI(datas[0]),datas[1],nameh,namey);
  23.                         }
  24.                 }
  25.         };
  26.         Sprite_Character.prototype.createNamepopSet = function(name,color,h,f) {
  27.                 this._namepopSprite = new Sprite();
  28.                 this._namepopSprite.bitmap = new Bitmap(h * 10, h);
  29.                 this._namepopSprite.bitmap.fontSize = h;
  30.                 this._namepopSprite.bitmap.textColor = color ;
  31.                 this._namepopSprite.bitmap.drawText(name, 0, 0, h * 10, h, 'center');
  32.                 this._namepopSprite.anchor.x = 0.5;
  33.                 this._namepopSprite.anchor.y = 1;
  34.                 this._namepopSprite.y = this.y - f * 48;
  35.                 this.addChild(this._namepopSprite);
  36.         };
  37. }()
  38. );
复制代码
不知道这个算不算侵权啊= =版主大大手下留情。

评分

参与人数 1梦石 +1 收起 理由
余烬之中 + 1 0x0

查看全部评分

Lv3.寻梦者

梦石
0
星屑
3664
在线时间
826 小时
注册时间
2013-7-29
帖子
161

开拓者

2
发表于 2016-1-18 11:48:57 | 只看该作者
不算侵权 ,想怎么改就怎么改。

点评

他昨天晚上更新了帖子,已经解决l,不过还是谢谢你~~~~  发表于 2016-1-19 10:13
并不能联系到,你还是直接@他吧  发表于 2016-1-18 16:40
3Q~~~~其实我还想问,dongdongdjh,你联系到rpg-sheep不?我想知道TA的任务系统那个脚本为什么完成任务之后得不到奖励的问题。  发表于 2016-1-18 14:29
现在论坛上的少,有事联系
QQ:2287688663
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
90 小时
注册时间
2007-8-14
帖子
25
3
发表于 2016-1-18 17:26:41 | 只看该作者
{:2_276:}这个脚本当这个NPC有时显示有时不显示时就崩了……只能给一些固定NPC使用
我的意思是比如有个NPC,你可以把他杀死,但是杀死他之后名字还留在上面
大大们看看,能不能为不同的事件页显示不同的名字
我看日文站有个 但是看不懂怎么用

点评

打错了,是MOG_Eventtext  发表于 2016-1-19 10:22
你说的是MOG_Eventext么?如果是这个插件的默认状态,你只需要在事件页的第一行写一个说明(MV以前叫注释)内容为“event text: 你想显示的文字",就行了   发表于 2016-1-19 10:21
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
90 小时
注册时间
2007-8-14
帖子
25
4
发表于 2016-1-19 10:46:52 | 只看该作者
我说的是这个插件……不知道怎么使用。
你这个插件满足不了我的需求,比如某个NPC在某些情况下如果不出现的话,但头顶还会出现字……


name(日文插件)

点评

我再看看怎么使用~~~  发表于 2016-1-19 11:48
目测这个插件有点厉害,支持各种\,我看到的好像有\C[n],\V[n],\N[n],\P[n],\G,这些可以像显示文字的时候那样直接输入,然后显示到NPC头上  发表于 2016-1-19 11:47
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
5
 楼主| 发表于 2016-1-19 16:28:15 | 只看该作者
chaizi1992 发表于 2016-1-19 10:46
我说的是这个插件……不知道怎么使用。
你这个插件满足不了我的需求,比如某个NPC在某些情况下如果不出现的 ...


我败了,实在是看不明白哪里有问题= =我看了注释的写法,也测试了匹配的返回值,并没有什么问题,但是就是不工作= =不明白这个插件要怎么用。
不过我测试了MOG的那个MOG_EventText。发现应该可以应用于你的要求下,代码放下面,用法这里给你解释一下:在事件页里面的第一行(注意不是事件名称和注释栏,是些时间内容的页面里),选择事件命令里面左下角的那个说明(以前叫注释)的选项,然后写入eventtext|测试|#ff0000。注意分割符,中间不留空格。颜色不能为空,为空会显示奇异的黑色= =白色的代码是#ffffff。
你可以在同一个事件的不同页中设置不同的标签,通过独立开关或者其他让事件激活不同页的方式来切换事件头上显示的文字。
以下为代码。
  1. //=============================================================================
  2. // MOG_EventText.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc (v1.0) Adiciona um texto em cima do evento.
  6. * @author Moghunter
  7. *
  8. * @param X axis
  9. * @desc Definição da posição X-axis.
  10. * @default 0
  11. *
  12. * @param Y axis
  13. * @desc Definição da posição Y-axis.
  14. * @default 0
  15. *
  16. * @param Font Size
  17. * @desc Definição do tamanho da fonte.
  18. * @default 18
  19. *
  20. * @help  
  21. * =============================================================================
  22. * +++ MOG - Event Text (v1.0) +++
  23. * By Moghunter
  24. * https://atelierrgss.wordpress.com/
  25. * =============================================================================
  26. * Adiciona um texto acima do evento, útil para fazer tutoriais.
  27. * =============================================================================
  28. * Para ativar o texto no evento use o seguinte comentário no evento.
  29. *
  30. *  event text: TEXT
  31. *
  32. * Exemplo.
  33. *
  34. *  event text: I'm The Boss
  35. *
  36. */

  37. //=============================================================================
  38. // ** PLUGIN PARAMETERS
  39. //=============================================================================
  40.   var Imported = Imported || {};
  41.   Imported.MOG_EventText = true;
  42.   var Moghunter = Moghunter || {};

  43.    Moghunter.parameters = PluginManager.parameters('MOG_EventText');
  44.     Moghunter.charText_x = Number(Moghunter.parameters['X axis'] || 0);
  45.         Moghunter.charText_y = Number(Moghunter.parameters['Y axis'] || 0);
  46.     Moghunter.charText_Size = Number(Moghunter.parameters['Font Size'] || 18);
  47.        
  48. //=============================================================================
  49. // ** Character Base
  50. //=============================================================================

  51. //==============================
  52. // * Init Members
  53. //==============================
  54. var _alias_mog_eventext_cbase_initMembers = Game_CharacterBase.prototype.initMembers;
  55. Game_CharacterBase.prototype.initMembers = function() {
  56.     _alias_mog_eventext_cbase_initMembers.call(this);
  57.         this._char_text = [false,""];
  58. };

  59. //=============================================================================
  60. // ** Game Event
  61. //=============================================================================

  62. //==============================
  63. // * Setup Page
  64. //==============================
  65. var _alias_mog_eventext_gevent_setupPage = Game_Event.prototype.setupPage;
  66. Game_Event.prototype.setupPage = function() {
  67.         _alias_mog_eventext_gevent_setupPage.call(this);
  68.     this.check_event_text();
  69. };

  70. //==============================
  71. // * Check Event Text
  72. //==============================
  73. Game_Event.prototype.check_event_text = function() {
  74.         this._need_clear_text = true
  75.         if (!this._erased && this.page()) {this.list().forEach(function(l) {
  76.                if (l.code === 108) {var comment = l.parameters[0].split('|')
  77.                            if (comment[0].toLowerCase() == "eventtext"){
  78.                   this._char_text = [true,String(comment[1]),String(comment[2])];
  79.                                   this._need_clear_text = false;                          
  80.                            };};
  81.         }, this);};
  82.         if (this._need_clear_text) {this._char_text = [true,""]};
  83. };

  84. //=============================================================================
  85. // ** Sprite Character
  86. //=============================================================================

  87. //==============================
  88. // * Initialize
  89. //==============================
  90. var _alias_mog_eventext_schar_initialize = Sprite_Character.prototype.initialize;
  91. Sprite_Character.prototype.initialize = function(character) {
  92.     _alias_mog_eventext_schar_initialize.call(this,character);
  93.         if (this._character && this._character._eventId) {this._character.check_event_text()};
  94. };

  95. //=============================================================================
  96. // ** Spriteset Map
  97. //=============================================================================

  98. //==============================
  99. // * create Lower Layer
  100. //==============================
  101. var _alias_mog_eventext_srmap_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
  102. Spriteset_Map.prototype.createLowerLayer = function() {
  103.         _alias_mog_eventext_srmap_createLowerLayer.call(this);
  104.         this.create_event_text_field();
  105. };

  106. //==============================
  107. // * create Event Text Field
  108. //==============================
  109. Spriteset_Map.prototype.create_event_text_field = function() {
  110.         this._etextField = new Sprite();
  111.         this._baseSprite.addChild(this._etextField);
  112.         this._sprite_char_text = [];
  113.         for (var i = 0; i < this._characterSprites.length; i++) {
  114.              this._sprite_char_text[i] = new Sprite_CharText(this._characterSprites[i]);
  115.                  this._etextField.addChild(this._sprite_char_text[i]);
  116.     };
  117. };

  118. //=============================================================================
  119. // ** Sprite CharText
  120. //=============================================================================
  121. function Sprite_CharText() {
  122.     this.initialize.apply(this, arguments);
  123. };

  124. Sprite_CharText.prototype = Object.create(Sprite.prototype);
  125. Sprite_CharText.prototype.constructor = Sprite_CharText;

  126. //==============================
  127. // * Initialize
  128. //==============================
  129. Sprite_CharText.prototype.initialize = function(target) {
  130.     Sprite.prototype.initialize.call(this);
  131.         this.sprite_char = target;
  132. };

  133. //==============================
  134. // * Character
  135. //==============================
  136. Sprite_CharText.prototype.character = function() {
  137.          return this.sprite_char._character;
  138. };

  139. //==============================
  140. // * Update Char Text
  141. //==============================
  142. Sprite_CharText.prototype.update = function() {
  143.         Sprite.prototype.update.call(this);
  144.         if (this.character()._char_text[0]) {this.refresh_char_text()};
  145.         if (!this._char_text) {return};
  146.         this._char_text.x = this.textX_axis();
  147.         this._char_text.y = this.textY_axis();
  148. };

  149. //==============================
  150. // * Create Char Text
  151. //==============================
  152. Sprite_CharText.prototype.create_char_text = function() {
  153.          if (this._char_text) {this.removeChild(this._char_text)};
  154.          if (this.character()._char_text[1] === "") {return};
  155.      this._char_text = new Sprite(new Bitmap(90,32));
  156.          this._char_text.anchor.x = 0.5;
  157.          this._char_text.y = -(this.sprite_char.patternHeight());
  158.          this._char_text.bitmap.fontSize = Moghunter.charText_Size;
  159.          this.addChild(this._char_text);
  160. };

  161. //==============================
  162. // * Refresh Char Text
  163. //==============================
  164. Sprite_CharText.prototype.refresh_char_text = function() {
  165.     this.create_char_text();
  166.         this.character()._char_text[0] = false;
  167.         if (this.character()._char_text[1] === "") {return};
  168.         var text = this.character()._char_text[1];
  169.         this._char_text.bitmap.clear();
  170.         var color = this.character()._char_text[2];
  171.         this._char_text.bitmap.textColor = color;
  172.         this._char_text.bitmap.drawText(text,0,0,90,32,"center");
  173. };

  174. //==============================
  175. // * Text X Axis
  176. //==============================
  177. Sprite_CharText.prototype.textX_axis = function() {
  178.         return Moghunter.charText_x + this.sprite_char.x;
  179. };

  180. //==============================
  181. // * Text Y Axis
  182. //==============================
  183. Sprite_CharText.prototype.textY_axis = function() {
  184.         return -(this.sprite_char.patternHeight() + 24) + Moghunter.charText_y + this.sprite_char.y;
  185. };
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
90 小时
注册时间
2007-8-14
帖子
25
6
发表于 2016-1-19 17:41:00 | 只看该作者
salvareless 发表于 2016-1-19 16:28
我败了,实在是看不明白哪里有问题= =我看了注释的写法,也测试了匹配的返回值,并没有什么问题,但是就 ...

{:2_280:}谢谢大触,我已经被那个日版插件搞崩溃了,现在用这个MOG的试下

点评

不不不,我不是大触,我不会写代码的= =我只是观察修改而已,能帮到你我也很开心。  发表于 2016-1-19 18:04
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 18:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表