Project1

标题: 请问怎么修改Window_Status脚本使它能显示角色说明? [打印本页]

作者: zphyp120    时间: 2011-8-3 17:28
标题: 请问怎么修改Window_Status脚本使它能显示角色说明?
本帖最后由 zphyp120 于 2011-8-3 17:29 编辑

我把原脚本修改成了这样:(因为人物半身像太矮,又在左上角,所以我想在左下角添加一个角色说明)
  1. class Window_Status < Window_Base
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对像
  4.   #     actor : 角色
  5.   #--------------------------------------------------------------------------
  6.   def initialize(actor)
  7.     super(0, 0, 640, 480)
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @actor = actor
  10.     refresh
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 刷新
  14.   #--------------------------------------------------------------------------
  15.   def refresh
  16.     self.contents.clear
  17.     for i in 0...1
  18.       actor = $game_party.actors[i]
  19.       case i
  20.       when 0
  21.       self.contents.draw_text(259, 399, 80, 32, "XXXXXXXXXXXXXXXXXXXXXXXXXX")

  22.       
  23.     self.contents.clear
  24.     bustname = @actor.id.to_s + "_b"
  25.     bitmap=Bitmap.new("Graphics/pictures/#{bustname}")
  26.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  27.     self.contents.blt(0, 0, bitmap, src_rect)
  28.    
  29.     draw_actor_name(@actor, 260, 0)
  30.     draw_actor_class(@actor, 360, 32)
  31.     draw_actor_level(@actor, 260, 32)
  32.     draw_actor_state(@actor, 380, 0)
  33.     draw_actor_hp(@actor, 260, 64, 172)
  34.     draw_actor_sp(@actor, 260, 96, 172)
  35.     draw_actor_parameter(@actor, 440, 66, 0)
  36.     draw_actor_parameter(@actor, 440, 96, 1)
  37.     draw_actor_parameter(@actor, 440, 130, 2)
  38.     draw_actor_parameter(@actor, 260, 162, 3)
  39.     draw_actor_parameter(@actor, 260, 194, 4)
  40.     draw_actor_parameter(@actor, 440, 162, 5)
  41.     draw_actor_parameter(@actor, 440, 194, 6)
  42.     self.contents.font.color = Color.new(255,255,0,255)
  43.     self.contents.draw_text(259, 399, 80, 32, "EXP")
  44.     self.contents.draw_text(439, 399, 80, 32, "NEXT")
  45.     self.contents.font.color = normal_color
  46.     self.contents.draw_text(260 + 80, 400, 84, 32, @actor.exp_s, 2)
  47.     self.contents.draw_text(440 + 80, 400, 84, 32, @actor.next_rest_exp_s, 2)
  48.     self.contents.font.color = Color.new(255,255,0,255)
  49.     self.contents.draw_text(260, 240, 96, 32, "装备")
  50.     draw_item_name($data_weapons[@actor.weapon_id], 260, 270)
  51.     draw_item_name($data_armors[@actor.armor1_id], 420, 270)
  52.     draw_item_name($data_armors[@actor.armor2_id], 260, 310)
  53.     draw_item_name($data_armors[@actor.armor3_id], 420, 310)
  54.     draw_item_name($data_armors[@actor.armor4_id], 260, 350)
  55.   end
  56.   end
  57.   end
  58. end
复制代码
我的想法就是用case语句来判断角色显示不同角色的人物说明。dsu_plus_rewardpost_czw
作者: Wind2010    时间: 2011-8-3 17:39
  1. case $game_party.actors[i].id
  2. when 1
  3.   self.contents.draw_text(259, 399, 80, 32, "1号角色的说明")
  4. when 2
  5.   self.contents.draw_text(259, 399, 80, 32, "2号角色的说明")
  6. else
  7.   self.contents.draw_text(259, 399, 80, 32, "以此类推,可以增加")
  8. end
复制代码
替换的位置你应该懂的
作者: zphyp120    时间: 2011-8-3 18:12
Wind2010 发表于 2011-8-3 17:39
替换的位置你应该懂的

还是显示不能:
  1. class Window_Status < Window_Base
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化对像
  4.   #     actor : 角色
  5.   #--------------------------------------------------------------------------
  6.   def initialize(actor)
  7.     super(0, 0, 640, 480)
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     @actor = actor
  10.     refresh
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # ● 刷新
  14.   #--------------------------------------------------------------------------
  15.   def refresh
  16.     self.contents.clear
  17.     for i in 0...1
  18.       actor = $game_party.actors[i]
  19.       case $game_party.actors[i].id
  20.       when 1
  21.         self.contents.font.color = Color.new(255,255,0,255)
  22.         self.contents.draw_text(259, 399, 80, 32, "1号角色的说明")
  23.       when 2
  24.         self.contents.font.color = Color.new(255,255,0,255)
  25.         self.contents.draw_text(259, 399, 80, 32, "2号角色的说明")
  26.       end
  27.       
  28.     self.contents.clear
  29.     bustname = @actor.id.to_s + "_b"
  30.     bitmap=Bitmap.new("Graphics/pictures/#{bustname}")
  31.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  32.     self.contents.blt(0, 0, bitmap, src_rect)
  33.    
  34.     draw_actor_name(@actor, 260, 0)
  35.     draw_actor_class(@actor, 360, 32)
  36.     draw_actor_level(@actor, 260, 32)
  37.     draw_actor_state(@actor, 380, 0)
  38.     draw_actor_hp(@actor, 260, 64, 172)
  39.     draw_actor_sp(@actor, 260, 96, 172)
  40.     draw_actor_parameter(@actor, 440, 66, 0)
  41.     draw_actor_parameter(@actor, 440, 96, 1)
  42.     draw_actor_parameter(@actor, 440, 130, 2)
  43.     draw_actor_parameter(@actor, 260, 162, 3)
  44.     draw_actor_parameter(@actor, 260, 194, 4)
  45.     draw_actor_parameter(@actor, 440, 162, 5)
  46.     draw_actor_parameter(@actor, 440, 194, 6)
  47.     self.contents.font.color = Color.new(255,255,0,255)
  48.     self.contents.draw_text(259, 399, 80, 32, "EXP")
  49.     self.contents.draw_text(439, 399, 80, 32, "NEXT")
  50.     self.contents.font.color = normal_color
  51.     self.contents.draw_text(260 + 80, 400, 84, 32, @actor.exp_s, 2)
  52.     self.contents.draw_text(440 + 80, 400, 84, 32, @actor.next_rest_exp_s, 2)
  53.     self.contents.font.color = Color.new(255,255,0,255)
  54.     self.contents.draw_text(260, 240, 96, 32, "装备")
  55.     draw_item_name($data_weapons[@actor.weapon_id], 260, 270)
  56.     draw_item_name($data_armors[@actor.armor1_id], 420, 270)
  57.     draw_item_name($data_armors[@actor.armor2_id], 260, 310)
  58.     draw_item_name($data_armors[@actor.armor3_id], 420, 310)
  59.     draw_item_name($data_armors[@actor.armor4_id], 260, 350)
  60.   end
  61.   end
  62. end
复制代码

作者: 凌冰    时间: 2011-8-3 18:22
本帖最后由 凌冰 于 2011-8-3 18:24 编辑
zphyp120 发表于 2011-8-3 18:12
还是显示不能:


这代码写的真纠结
把for语句去掉(再去掉一个end)
actor = $game_party.actors也去掉
case语句改成 case @actor.id
28行也去掉。。。
作者: zphyp120    时间: 2011-8-3 18:27
谢谢凌冰君,也感谢Wind2010提供思路
作者: IamI    时间: 2011-8-3 18:27
本帖最后由 IamI 于 2011-8-3 18:27 编辑

= =|| 其实我想说,改完颜色以后就放着不管了很可能会出一些奇怪的颜色BUG
其实发这贴的主要目的是看望LSS = =b




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