Project1

标题: 关于状态窗口改造(依据角色不同自定义不同背景)的问题 [打印本页]

作者: 负零    时间: 2016-1-18 22:34
标题: 关于状态窗口改造(依据角色不同自定义不同背景)的问题
本帖最后由 负零 于 2016-1-18 22:35 编辑

经过@夏末渐离的提示(准确说是枪手),已经解决了插入问题,但现在另外一个问题难住了,就是依据角色不同自定义不同背景。在VA上是实现的,也请各位大神指导指导。
首先以下第一段已经获取到actor(应该已经含了id,个人理解),this.draw_backg(this._actor)已经描绘背景并把this._actor传入函数。
JAVASCRIPT 代码复制
  1. Window_Status.prototype.setActor = function(actor) {
  2.     if (this._actor !== actor) {
  3.         this._actor = actor;
  4.         this.refresh();
  5.     }
  6. };
  7.  
  8. Window_Status.prototype.refresh = function() {
  9.     this.contents.clear();
  10.     if (this._actor) {
  11.         var lineHeight = this.lineHeight();
  12.         // this.drawBlock1(lineHeight * 0);
  13.         this.drawHorzLine(lineHeight * 1);
  14.         // this.drawBlock2(lineHeight * 2);
  15.         this.drawHorzLine(lineHeight * 6);
  16.         this.drawBlock3(lineHeight * 7);
  17.         this.drawHorzLine(lineHeight * 13);
  18.         this.drawBlock4(lineHeight * 14);
  19.                 this.draw_backg(this._actor);
  20.     }
  21. };

绘制背景的函数,我觉得,问题应该存在于嵌入式表达this.back_sprite.bitmap=ImageManager.loadBattleback1("Status_+#{id}"); 上,但怎么试都不对,同时对应的文件夹里是有个文件的,命名为Status_2,即进入2号ID的角色的状态查看窗口,则背景自动替换成Status_2,类推,1号则Status_1,5号则Status_5。
JAVASCRIPT 代码复制
  1. Window_Status.prototype.draw_backg = function(id)
  2. {
  3.     //this.contents.clear();
  4.         this.back_sprite=new Sprite();
  5.     this.back_sprite.bitmap=ImageManager.loadBattleback1("Status_+#{id}");
  6.         this.addChild(this.back_sprite);
  7.     this.addChildToBack(this.back_sprite); //or this.addChildAt(child,index);
  8. };

问题截图,那几串百分号是什么鬼?求教。

作者: 西姐    时间: 2016-1-18 22:45
有个插件可以换立绘,但它根据的是队伍位置,我也想改成根据数据库ID的


作者: trentswd    时间: 2016-1-19 03:25
转义符啊
比如空格就是%20
为了防止麻烦,保持文件名里面只有大小写英文和数字和下划线就没有这种烦恼了……
作者: 夜狠简单    时间: 2016-1-19 04:26
JAVASCRIPT 代码复制
  1. /*:
  2. *@plugindesc        给角色简单的增加自己的背景。
  3. @author        - -
  4. @param       
  5. @desc       
  6. @default       
  7. *@help        例如一号角色叫’哈罗德‘,则在img\battlebacks1文件下放一张命名为
  8. *Status_哈罗德.png的图片作为角色背景图 ,默认透明度140
  9. */
  10.  
  11.  
  12.  
  13. (function() {
  14.  
  15.  
  16.  
  17. Window_Status.prototype = Object.create(Window_Selectable.prototype);
  18. Window_Status.prototype.constructor = Window_Status;
  19.  
  20. Window_Status.prototype.initialize = function() {
  21.     var width = Graphics.boxWidth;
  22.     var height = Graphics.boxHeight;
  23.     Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  24.     this.refresh();
  25.     this.activate();
  26. };
  27.  
  28.  
  29.  
  30. Window_Status.prototype.setActor = function(actor) {
  31.     if (this._actor !== actor) {
  32.         this._actor = actor;
  33. //=====================================================
  34.                 this.removeChild(this.backSprite2);
  35. //=====================================================
  36.         this.refresh();
  37.     }
  38. };
  39.  
  40.  
  41.  
  42. Window_Status.prototype.refresh = function() {
  43.     this.contents.clear();
  44.     if (this._actor) {
  45.         var lineHeight = this.lineHeight();
  46.         this.drawBlock1(lineHeight * 0);
  47.         this.drawHorzLine(lineHeight * 1);
  48.         this.drawBlock2(lineHeight * 2);
  49.         this.drawHorzLine(lineHeight * 6);
  50.         this.drawBlock3(lineHeight * 7);
  51.         this.drawHorzLine(lineHeight * 13);
  52.         this.drawBlock4(lineHeight * 14);
  53. //=========================================================================
  54.                 var bitm='Status_'+this._actor.name();//读取 Status_角色名 图片
  55.                 this.backSprite2 = new Sprite(ImageManager.loadBattleback1(bitm));
  56.             this.backSprite2.opacity=140;//透明度设置
  57.             this.addChild(this.backSprite2);
  58. //=========================================================================
  59.     };
  60. };
  61.  
  62. Window_Status.prototype.drawBlock1 = function(y) {
  63.     this.drawActorName(this._actor, 6, y);
  64.     this.drawActorClass(this._actor, 192, y);
  65.     this.drawActorNickname(this._actor, 432, y);
  66. };
  67.  
  68. Window_Status.prototype.drawBlock2 = function(y) {
  69.     this.drawActorFace(this._actor, 12, y);
  70.     this.drawBasicInfo(204, y);
  71.     this.drawExpInfo(456, y);
  72. };
  73.  
  74. Window_Status.prototype.drawBlock3 = function(y) {
  75.     this.drawParameters(48, y);
  76.     this.drawEquipments(432, y);
  77. };
  78.  
  79. Window_Status.prototype.drawBlock4 = function(y) {
  80.     this.drawProfile(6, y);
  81. };
  82.  
  83. Window_Status.prototype.drawHorzLine = function(y) {
  84.     var lineY = y + this.lineHeight() / 2 - 1;
  85.     this.contents.paintOpacity = 48;
  86.     this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
  87.     this.contents.paintOpacity = 255;
  88. };
  89.  
  90. Window_Status.prototype.lineColor = function() {
  91.     return this.normalColor();
  92. };
  93.  
  94. Window_Status.prototype.drawBasicInfo = function(x, y) {
  95.     var lineHeight = this.lineHeight();
  96.     this.drawActorLevel(this._actor, x, y + lineHeight * 0);
  97.     this.drawActorIcons(this._actor, x, y + lineHeight * 1);
  98.     this.drawActorHp(this._actor, x, y + lineHeight * 2);
  99.     this.drawActorMp(this._actor, x, y + lineHeight * 3);
  100. };
  101.  
  102. Window_Status.prototype.drawParameters = function(x, y) {
  103.     var lineHeight = this.lineHeight();
  104.     for (var i = 0; i < 6; i++) {
  105.         var paramId = i + 2;
  106.         var y2 = y + lineHeight * i;
  107.         this.changeTextColor(this.systemColor());
  108.         this.drawText(TextManager.param(paramId), x, y2, 160);
  109.         this.resetTextColor();
  110.         this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right');
  111.     }
  112. };
  113.  
  114. Window_Status.prototype.drawExpInfo = function(x, y) {
  115.     var lineHeight = this.lineHeight();
  116.     var expTotal = TextManager.expTotal.format(TextManager.exp);
  117.     var expNext = TextManager.expNext.format(TextManager.level);
  118.     var value1 = this._actor.currentExp();
  119.     var value2 = this._actor.nextRequiredExp();
  120.     if (this._actor.isMaxLevel()) {
  121.         value1 = '-------';
  122.         value2 = '-------';
  123.     }
  124.     this.changeTextColor(this.systemColor());
  125.     this.drawText(expTotal, x, y + lineHeight * 0, 270);
  126.     this.drawText(expNext, x, y + lineHeight * 2, 270);
  127.     this.resetTextColor();
  128.     this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
  129.     this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
  130. };
  131.  
  132. Window_Status.prototype.drawEquipments = function(x, y) {
  133.     var equips = this._actor.equips();
  134.     var count = Math.min(equips.length, this.maxEquipmentLines());
  135.     for (var i = 0; i < count; i++) {
  136.         this.drawItemName(equips[i], x, y + this.lineHeight() * i);
  137.     }
  138. };
  139.  
  140. Window_Status.prototype.drawProfile = function(x, y) {
  141.     this.drawTextEx(this._actor.profile(), x, y);
  142. };
  143.  
  144. Window_Status.prototype.maxEquipmentLines = function() {
  145.     return 6;
  146. };
  147.  
  148. })();



作者: 负零    时间: 2016-1-19 17:22
感谢楼上,我先试试。
作者: 负零    时间: 2016-1-24 12:19
夜狠简单 发表于 2016-1-19 04:26
/*:
*@plugindesc        给角色简单的增加自己的背景。
@author        - -

已经弄好
  1. //-----------------------------------------------------------------------------
  2. // Window_Status
  3. //
  4. // The window for displaying full status on the status screen.

  5. function Window_Status() {
  6.     this.initialize.apply(this, arguments);
  7. }

  8. Window_Status.prototype = Object.create(Window_Selectable.prototype);
  9. Window_Status.prototype.constructor = Window_Status;

  10. Window_Status.prototype.initialize = function() {
  11.     var width = Graphics.boxWidth;
  12.     var height = Graphics.boxHeight;
  13.     Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  14.         this.opacity = 0;
  15.     this.refresh();
  16.     this.activate();
  17. };

  18. Window_Status.prototype.setActor = function(actor) {
  19.     if (this._actor !== actor) {
  20.         this._actor = actor;
  21.                 this.removeChild(this.backSprite2);
  22.         this.refresh();
  23.     }
  24. };

  25. Window_Status.prototype.refresh = function() {
  26.     this.contents.clear();
  27.     if (this._actor) {
  28.         var lineHeight = this.lineHeight();
  29.         // this.drawBlock1(lineHeight * 0);
  30.         this.drawHorzLine(lineHeight * 1);
  31.         // this.drawBlock2(lineHeight * 2);
  32.         this.drawHorzLine(lineHeight * 6);
  33.         this.drawBlock3(lineHeight * 7);
  34.         this.drawHorzLine(lineHeight * 13);
  35.         this.drawBlock4(lineHeight * 14);
  36.                 this.draw_backg();
  37.                 // =========================================
  38.                                 // var bitm='Status_'+this._actor.name();//读取 Status_角色名 图片
  39.                 // this.backSprite2 = new Sprite(ImageManager.loadBattleback1(bitm));
  40.             // this.backSprite2.opacity=255;//透明度设置
  41.             // this.addChild(this.backSprite2);
  42.                         // =========================================
  43.     }
  44. };

  45. Window_Status.prototype.drawBlock1 = function(y) {
  46.     this.drawActorName(this._actor, 6, y);
  47.     this.drawActorClass(this._actor, 192, y);
  48.     this.drawActorNickname(this._actor, 432, y);
  49. };

  50. Window_Status.prototype.drawBlock2 = function(y) {
  51.     this.drawActorFace(this._actor, 12, y);
  52.     this.drawBasicInfo(204, y);
  53.     this.drawExpInfo(456, y);
  54. };

  55. Window_Status.prototype.drawBlock3 = function(y) {
  56.     this.drawParameters(48, y);
  57.     // this.drawEquipments(432, y);
  58. };

  59. Window_Status.prototype.drawBlock4 = function(y) {
  60.     this.drawProfile(6, y);
  61. };

  62. Window_Status.prototype.drawHorzLine = function(y) {
  63.     var lineY = y + this.lineHeight() / 2 - 1;
  64.     this.contents.paintOpacity = 48;
  65.     this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.lineColor());
  66.     this.contents.paintOpacity = 255;
  67. };

  68. Window_Status.prototype.lineColor = function() {
  69.     return this.normalColor();
  70. };

  71. Window_Status.prototype.drawBasicInfo = function(x, y) {
  72.     var lineHeight = this.lineHeight();
  73.     this.drawActorLevel(this._actor, x, y + lineHeight * 0);
  74.     this.drawActorIcons(this._actor, x, y + lineHeight * 1);
  75.     this.drawActorHp(this._actor, x, y + lineHeight * 2);
  76.     this.drawActorMp(this._actor, x, y + lineHeight * 3);
  77. };

  78. Window_Status.prototype.drawParameters = function(x, y) {
  79.     var lineHeight = this.lineHeight();
  80.     for (var i = 0; i < 6; i++) {
  81.         var paramId = i + 2;
  82.         var y2 = y + lineHeight * i;
  83.         this.changeTextColor(this.systemColor());
  84.         this.drawText(TextManager.param(paramId), x, y2, 160);
  85.         this.resetTextColor();
  86.         this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right');
  87.     }
  88. };

  89. Window_Status.prototype.drawExpInfo = function(x, y) {
  90.     var lineHeight = this.lineHeight();
  91.     var expTotal = TextManager.expTotal.format(TextManager.exp);
  92.     var expNext = TextManager.expNext.format(TextManager.level);
  93.     var value1 = this._actor.currentExp();
  94.     var value2 = this._actor.nextRequiredExp();
  95.     if (this._actor.isMaxLevel()) {
  96.         value1 = '-------';
  97.         value2 = '-------';
  98.     }
  99.     this.changeTextColor(this.systemColor());
  100.     this.drawText(expTotal, x, y + lineHeight * 0, 270);
  101.     this.drawText(expNext, x, y + lineHeight * 2, 270);
  102.     this.resetTextColor();
  103.     this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
  104.     this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
  105. };

  106. Window_Status.prototype.drawEquipments = function(x, y) {
  107.     var equips = this._actor.equips();
  108.     var count = Math.min(equips.length, this.maxEquipmentLines());
  109.     for (var i = 0; i < count; i++) {
  110.         this.drawItemName(equips[i], x, y + this.lineHeight() * i);
  111.     }
  112. };

  113. Window_Status.prototype.drawProfile = function(x, y) {
  114.     this.drawTextEx(this._actor.profile(), x, y);
  115. };

  116. Window_Status.prototype.maxEquipmentLines = function() {
  117.     return 6;
  118. };

  119. Window_Status.prototype.draw_backg = function()
  120. {
  121.     var bitm='Status_'+this._actor.name();//读取 Status_角色名 图片
  122.         //this.contents.clear();
  123.         this.back_sprite=new Sprite();
  124.     this.back_sprite.bitmap=ImageManager.loadBattleback1(bitm);
  125.         this.back_sprite.opacity=255
  126.         this.addChild(this.back_sprite);
  127.     this.addChildToBack(this.back_sprite); //or this.addChildAt(child,index);
  128. };
复制代码
帮忙看看,有哪个地方不妥的。
作者: lirhtc    时间: 2016-3-25 18:01
请问您是如何用谷歌的这个Developer Tools 来调试MV程序的,方便告知一下吗?十分感谢




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1