Project1

标题: 战斗结束物品显示 [打印本页]

作者: 黑米馒头    时间: 2015-2-3 13:42
标题: 战斗结束物品显示
XP默认的脚本,战斗结束之后,会显示获得的 经验 金钱 物品这些,但是都是统一显示的,


我像改成分开显示,先显示经验和经验,接着显示物品,如果多个物品的话,就1个1个显示。

我是这么改的,不过总觉得有问题。来个朋友帮看下
  1. #==============================================================================
  2. # ■ Window_BattleResult
  3. #------------------------------------------------------------------------------
  4. #  战斗结束时、显示获得的 EXP 及金钱的窗口。
  5. #==============================================================================

  6. class Window_BattleResult < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     exp       : EXP
  10.   #     gold      : 金钱
  11.   #     treasures : 宝物
  12.   #--------------------------------------------------------------------------
  13.   def initialize(exp, gold, treasures)
  14.     @exp = exp
  15.     @gold = gold
  16.     @treasures = treasures
  17.     super(160,200-20, 310,@treasures.size * 24 + 64 -16)
  18.     self.contents = Bitmap.new(width - 32, height - 32)
  19.     self.back_opacity = 255
  20.     self.y = 240 - height / 2
  21.     self.z = 1000
  22.     self.visible = false
  23.     refresh
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 刷新
  27.   #--------------------------------------------------------------------------
  28.   def refresh
  29.    for actor in $game_party.actors
  30.     self.contents.font.name = (["宋体","黑体"])
  31.     self.contents.font.bold = true                       # 字体粗细
  32.     self.contents.font.color = Color.new(255, 255, 88)   # 黄色
  33.     self.contents.font.size = 16
  34.       self.contents.draw_text(-1, -8,300, 32,"你得到了" + @exp.to_s + "点经验和" + @gold.to_s + "两银子。")
  35.       self.contents.draw_text(-1, 16,300, 32,"你获得了" + @tiem_name.to_s)
  36.       self.contents.draw_text(-1, 40,300, 32,"你获得了" + @tiem_name.to_s)
  37.       self.contents.draw_text(-1, 40+(24*1), 300, 32,"你获得了" + @tiem_name.to_s)
  38.       self.contents.draw_text(-1, 40+(24*2), 300, 32,"你获得了" + @tiem_name.to_s)
  39.     y = 32
  40.     for item in @treasures
  41.       draw_item_name(item, 4+20, y)
  42.       y += 24
  43.     end
  44.   end
  45. end
复制代码

作者: rpg-sheep    时间: 2015-2-3 17:21
"你获得了" + @tiem_name.to_s

大神,你确认不是 @item_name.to_s?我醉了!
作者: guoxiaomi    时间: 2015-2-3 19:39
draw之间没有 等待 的话是不是也是一口气都显示了?
作者: 邪月长啸    时间: 2015-2-10 12:42
  1. #==============================================================================
  2. # ■ Window_BattleResult
  3. #------------------------------------------------------------------------------
  4. #  战斗结束时、显示获得的 EXP 及金钱的窗口。
  5. #==============================================================================

  6. class Window_BattleResult < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     exp       : EXP
  10.   #     gold      : 金钱
  11.   #     treasures : 宝物
  12.   #--------------------------------------------------------------------------
  13.   def initialize(exp, gold, treasures)
  14.     @exp = exp
  15.     @gold = gold
  16.     @treasures = treasures
  17.    
  18.     super(160, 30, 320, 3 * 32 + 324)#@treasures.size * 32 + 164)
  19.     self.contents = Bitmap.new(width - 32, height - 32)
  20.     self.y = 160 - height / 2
  21.     self.z = 99999
  22.     #self.back_opacity = 160
  23.     #self.back_opacity = 0
  24.     self.windowskin = RPG::Cache.windowskin("")
  25.     #self.visible = false
  26.    
  27. #  if @treasures.size != 3
  28.     @win_window = Window_Base.new(260, 88, 118, 48)
  29. #   else
  30. #   @win_window = Window_Base.new(260, 88 + 40, 118, 48)
  31. #  end
  32.   
  33.     @win_window.contents = Bitmap.new(368, 32)
  34.     win_string = "战斗总结"
  35.     #@win_window.contents.font.name = "黑体"
  36.     @win_window.contents.font.size = 16
  37.     @win_window.contents.font.name = Font.default_name
  38.     #@win_window.contents.font.size = Font.default_size
  39.     @win_window.contents.font.color = Color.new(-255,-255,-255,255)
  40.     @win_window.contents.draw_text(8, -8, 78, 32, win_string)
  41.     @win_window.windowskin = RPG::Cache.windowskin("skin_pal2")
  42.    
  43. #  if @treasures.size != 3
  44.     @exp_window = Window_Base.new(225, 141, 188, 48)
  45. #  else
  46. #   @exp_window = Window_Base.new(225, 141 + 40, 188, 48)
  47. # end
  48.   
  49.     @exp_window.contents = Bitmap.new(368, 32)
  50.     exp_string = "获得经验值"
  51.     @exp_window.contents.font.size = 16
  52.     @exp_window.contents.font.name = Font.default_name
  53.     #@win_window.contents.font.size = Font.default_size
  54.     @exp_window.contents.font.color = Color.new(-255,-255,-255,255)
  55.     @exp_window.contents.draw_text(5, -8, 78, 32, exp_string)
  56.     @exp_window.visible = false
  57.     @exp_window.windowskin = RPG::Cache.windowskin("skin_pal2")
  58.    
  59.    
  60. #   if @treasures.size != 3
  61.     @money_window = Window_Base.new(190, 146 + 58 - 10, 268, 48)
  62. # else
  63. #    @money_window = Window_Base.new(190, 146 + 88, 268, 48)
  64. #  end
  65.     @money_window.contents = Bitmap.new(368, 32)
  66.     money_string = "打败敌人获得           文钱"
  67.     @money_window.contents.font.size = 16
  68.     @money_window.contents.font.name = Font.default_name
  69.     #@win_window.contents.font.size = Font.default_size
  70.     @money_window.contents.font.color = Color.new(-255,-255,-255,255)
  71.     @money_window.contents.draw_text(5, -8, 268, 32, money_string)
  72.     @money_window.z = 9999
  73.     @money_window.visible = false
  74.     @money_window.windowskin = RPG::Cache.windowskin("skin_pal2")
  75.    
  76.     #if @treasures.size != 3 and @treasures.size > 3
  77.     #@win_item_window = Window_Base.new(205, 146 + 116 - 15, 238, 48)
  78.     @win_item_window = Window_Base.new(180, 146 + 116 - 15, 290, 73)
  79.     #@win_item_window = Window_Base.new(205 + 48, 146 + 116 - 15, 118, 88)
  80.     @win_item_window.contents = Bitmap.new(368, 32)
  81.     win_item_string = "获得物品"
  82.     @win_item_window.contents.font.size = 16
  83.     @win_item_window.contents.font.name = Font.default_name
  84.     @win_item_window.contents.font.color = Color.new(-255,-255,-255,255)
  85.     @win_item_window.contents.draw_text(5, -8, 150, 32, win_item_string)
  86.     @win_item_window.z = 9999
  87.     @win_item_window.visible = false
  88.     @win_item_window.windowskin = RPG::Cache.windowskin("skin_pal2")
  89.    #   end
  90.       
  91.     refresh
  92.   end

  93.   #--------------------------------------------------------------------------
  94.   # ● 描绘物品名
  95.   #     item : 物品
  96.   #     x    : 描画目标 X 坐标
  97.   #     y    : 描画目标 Y 坐标
  98.   #--------------------------------------------------------------------------
  99.   def draw_item_name1(item, x, y)
  100.     if item == nil
  101.       return
  102.     end
  103.     bitmap = RPG::Cache.icon(item.icon_name)
  104.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  105.     self.contents.font.color = Color.new(-255, -255, -255, 255)
  106.     self.contents.font.size = 18
  107.     self.contents.draw_text(x +24, y, 212, 32, item.name)
  108.   end

  109.   #--------------------------------------------------------------------------
  110.   # ● 刷新
  111.   #--------------------------------------------------------------------------
  112.   def refresh
  113.     self.contents.clear
  114.     x = 4
  115.     #self.contents.font.color = normal_color
  116.    
  117.     20.times{Graphics.update}  
  118.    
  119.     @exp_window.visible = true
  120.     self.contents.font.color = Color.new(-255,-255,-255,255)
  121.     cx = contents.text_size(@exp.to_s).width
  122.     #self.contents.draw_text(155, 74, cx, 32, @exp.to_s)
  123.    
  124.    # if @treasures.size != 3
  125.     self.contents.draw_text(155, 74 + 114 - 5, cx, 32, @exp.to_s)
  126.    #   else
  127.   #  self.contents.draw_text(155, 74 + 114 + 35, cx, 32, @exp.to_s)
  128.   #  end
  129.     #self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
  130.     x += cx + 4
  131.    
  132.     20.times{Graphics.update}  

  133.     #self.contents.font.color = system_color
  134.     #cx = contents.text_size("").width
  135.     #self.contents.draw_text(x, 0, 64, 32, "")
  136.     #x += cx + 16
  137.    
  138.     #self.contents.font.color = normal_color
  139.     self.contents.font.color = Color.new(-255,-255,-255,255)
  140.     cx = contents.text_size(@gold.to_s).width
  141.     #self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
  142.     #self.contents.draw_text(145, 74 + 60, cx, 32, @gold.to_s)
  143.    
  144.     @money_window.visible = true
  145.    
  146.   #  if @treasures.size != 3
  147.     self.contents.draw_text(140, 74 + 172 - 10, cx, 32, @gold.to_s)
  148.    #   else
  149.   #  self.contents.draw_text(140, 74 + 172 + 30, cx, 32, @gold.to_s)
  150. # end
  151.   
  152.     x += cx + 4
  153.    
  154.     #self.contents.font.color = system_color
  155.     #self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
  156.     y = 282 + 26#21 - 15
  157.    
  158.     20.times{Graphics.update}  
  159.    
  160.     for item in @treasures
  161.       #self.contents.color = Color.new(-255,-255,-255,255)
  162.       #self.contents.draw_item_name(item, 90, y)
  163.    # if @treasures.size != 3 and @treasures.size > 3
  164.       @win_item_window.visible = true
  165.     #  end
  166.       draw_item_name1(item,x-20 ,286 + 25)#90, y)
  167.       #draw_item_name(item,90, y)
  168.       x += 120
  169.       y += 32
  170.    end
  171.     20.times{Graphics.update}  
  172.    
  173.   end
  174.   
  175.     def dispose
  176.       super
  177.       @win_window.dispose
  178.       @exp_window.dispose
  179.       @money_window.dispose
  180.       @win_item_window.dispose
  181.       end
  182. end
  183.   
复制代码





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