Project1

标题: 战斗状态栏在地图中如何显示 [打印本页]

作者: 远恒    时间: 2009-1-1 23:54
标题: 战斗状态栏在地图中如何显示
  1. #==============================================================================
  2. # ■ Window_BattleStatus
  3. #------------------------------------------------------------------------------
  4. #  显示战斗画面同伴状态的窗口。
  5. #==============================================================================

  6. class Window_BattleStatus < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 640, 480)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     @level_up_flags = [false, false, false, false]
  14.     #........................................................................
  15.     self.opacity = 0
  16.     @sta_back = []
  17.     @sta_output = []
  18.     @cp_output = []
  19.     @hp_bitmap = RPG::Cache.picture("../system/battle/hmcp/hp_bar.png")
  20.     @mp_bitmap = RPG::Cache.picture("../system/battle/hmcp/mp_bar.png")
  21.     @bitmap3 = RPG::Cache.picture("../system/battle/hmcp/底.png")
  22.      @cp_bitmap = RPG::Cache.picture("../system/battle/hmcp/cp_bar.png")
  23.     @cp_output = []
  24.     @cp_back_bar = Sprite.new
  25.     @cp_back_bar.bitmap = Bitmap.new("Graphics/system/battle/hmcp/cp_back_bar")
  26.     @cp_back_bar.x = 571
  27.     @cp_back_bar.y = 32
  28.     @cp_back_bar.z = self.z + 2
  29.    @actor_cp_sprite = []
  30.     @actor_cp_sprite_back = []

  31.     for actor_index in 1..$game_party.actors.size
  32.       @cp_output[actor_index] = Sprite.new
  33.       @cp_output[actor_index].bitmap = Bitmap.new(133, 78)
  34.       @cp_output[actor_index].x = 0 + (actor_index - 1) * 133
  35.       @cp_output[actor_index].y = 0 - 78 - 10
  36.       @cp_output[actor_index].z = self.z + 2
  37.       @cp_output[actor_index].bitmap.clear
  38.       @sta_back[actor_index] = Sprite.new
  39.       @sta_back[actor_index].bitmap = Bitmap.new("Graphics/System/Battle/sta_back/" + $game_party.actors[actor_index - 1].name + "战斗.png")
  40.       @sta_back[actor_index].x = 510
  41.       @sta_back[actor_index].y = 5 + (actor_index - 1) * 80
  42.       @sta_back[actor_index].z = self.z + 1
  43.       @sta_output[actor_index] = Sprite.new
  44.       @sta_output[actor_index].bitmap = Bitmap.new(133, 78)
  45.       @sta_output[actor_index].x = 505
  46.       @sta_output[actor_index].y = -36 + (actor_index - 1) * 80
  47.       @sta_output[actor_index].z = self.z + 2
  48.       @sta_output[actor_index].bitmap.clear
  49.       @sta_output[actor_index].bitmap.font.size = 10
  50.       @sta_output[actor_index].bitmap.font.name = "黑体"
  51.       hp_width = $game_party.actors[actor_index - 1].hp * @hp_bitmap.width/$game_party.actors[actor_index - 1].maxhp
  52.       hp_rect = Rect.new(0, 0, hp_width, 10)
  53.       mp_width = $game_party.actors[actor_index - 1].sp * @mp_bitmap.width/$game_party.actors[actor_index - 1].maxsp
  54.       mp_rect = Rect.new(0, 0, mp_width, 10)
  55.       
  56.       @src_rect3 = Rect.new(0,0,@bitmap3.width, @bitmap3.height)
  57.       self.contents.blt(10,220, @bitmap3, @src_rect3)
  58.       
  59.       @sta_output[actor_index].bitmap.blt(250, 44, @hp_bitmap, hp_rect)
  60.       @sta_output[actor_index].bitmap.blt(66, 64, @mp_bitmap, mp_rect)
  61.       @sta_output[actor_index].bitmap.blt(66, 54, @bitmap3, @src_rect3)
  62.       
  63.       @sta_output[actor_index].bitmap.font.color.set(255, 0, 0)
  64.       @sta_output[actor_index].bitmap.draw_text(80, 31, 77, 11,$game_party.actors[actor_index - 1].hp.to_s + "/" + $game_party.actors[actor_index - 1].maxhp.to_s)
  65.       @sta_output[actor_index].bitmap.font.color.set(0, 0, 255)
  66.       @sta_output[actor_index].bitmap.draw_text(80, 51, 77, 11,$game_party.actors[actor_index - 1].sp.to_s + "/" + $game_party.actors[actor_index - 1].maxsp.to_s)
  67.     end
  68.     #........................................................................
  69.     refresh
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # ● 释放
  73.   #--------------------------------------------------------------------------
  74.   def dispose
  75.     super
  76.     @hp_bitmap.bitmap.dispose
  77.     @hp_bitmap.dispose
  78.     @mp_bitmap.bitmap.dispose
  79.     @mp_bitmap.dispose
  80.     @cp_bitmap.bitmap.dispose
  81.     @cp_bitmap.dispose
  82.     for actor_index in 1..$game_party.actors.size
  83.       @sta_back[actor_index].bitmap.dispose
  84.       @sta_back[actor_index].dispose
  85.       @sta_output[actor_index].bitmap.dispose
  86.       @sta_output[actor_index].dispose
  87.       @cp_output[actor_index].bitmap.dispose
  88.       @cp_output[actor_index].dispose
  89.     end
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 设置升级标志
  93.   #     actor_index : 角色索引
  94.   #--------------------------------------------------------------------------
  95.   def level_up(actor_index)
  96.     @level_up_flags[actor_index] = true
  97.   end
  98.   #......................................................................
  99.   #--------------------------------------------------------------------------
  100.   # ● 设置正在攻击标志
  101.   #     actor_index : 角色索引
  102.   #--------------------------------------------------------------------------
  103.   def in_atk(actor_index)
  104.     @sta_back[actor_index + 1].bitmap = Bitmap.new("Graphics/System/Battle/sta_back/" + $game_party.actors[actor_index].name + "战斗1.png")
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 设置不在攻击标志
  108.   #     actor_index : 角色索引
  109.   #--------------------------------------------------------------------------
  110.   def out_atk(actor_index)
  111.     @sta_back[actor_index + 1].bitmap = Bitmap.new("Graphics/System/Battle/sta_back/" + $game_party.actors[actor_index].name + "战斗.png")
  112.   end
  113.   #......................................................................
  114.   #--------------------------------------------------------------------------
  115.   # ● 刷新
  116.   #--------------------------------------------------------------------------
  117.   def refresh
  118.     self.contents.clear
  119.     @item_max = $game_party.actors.size
  120.     for i in 0...$game_party.actors.size
  121.       actor = $game_party.actors[i]
  122.       #......................................................................
  123.        actor_x = i * 160 + 145
  124.        actor_y = i * 80 + 220
  125.       @sta_output[i + 1].bitmap.clear
  126.       hp_width = $game_party.actors[i].hp * @hp_bitmap.width/$game_party.actors[i].maxhp
  127.       hp_rect = Rect.new(0, 0, hp_width, 100)
  128.       mp_width = $game_party.actors[i].sp * @mp_bitmap.width/$game_party.actors[i].maxsp
  129.       mp_rect = Rect.new(0, 0, mp_width, 100)
  130.       @sta_output[i + 1].bitmap.blt(66, 44, @hp_bitmap, hp_rect)
  131.       @sta_output[i + 1].bitmap.blt(66, 56, @mp_bitmap, mp_rect)
  132.       @sta_output[i + 1].bitmap.font.color.set(255, 0, 0)
  133.       #@sta_output[i + 1].bitmap.draw_text(80, 31, 77, 11,$game_party.actors[i].hp.to_s + "/" + $game_party.actors[i].maxhp.to_s)
  134.       @sta_output[i + 1].bitmap.font.color.set(0, 0, 255)
  135.       #@sta_output[i + 1].bitmap.draw_text(80, 51, 77, 11,$game_party.actors[i].sp.to_s + "/" + $game_party.actors[i].maxsp.to_s)
  136.       #......................................................................
  137.       if @level_up_flags[i]
  138.         self.contents.font.color = normal_color
  139.         self.contents.draw_text(0, 0, 640 , 480, "LEVEL UP!")
  140.       else
  141.         draw_actor_state(actor, 120, actor_y)
  142.       end
  143.     end
  144.   end
  145.     #--------------------------------------------------------------------------
  146.   # ● 刷新画面
  147.   #--------------------------------------------------------------------------
  148.   def update
  149.         super
  150. #     主界面的不透明度下降
  151.     if $game_temp.battle_main_phase
  152.       self.contents_opacity = 255 #if self.contents_opacity > 1
  153.     else
  154.       self.contents_opacity = 255 #if self.contents_opacity < 255
  155.     end
  156.   end
  157. end
复制代码

请问如何在正常地图中也显示它.而不是只在战斗才显示这个状态栏 [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 风花雪月    时间: 2009-1-2 00:15
http://rpg.blue/web/htm/news568.htm是这个吧
作者: 远恒    时间: 2009-1-2 00:19
不是.{/pz}哪位大哥大姐会啊?教教我
作者: 风花雪月    时间: 2009-1-2 00:43
http://rpg.blue/web/htm/news816.htm这次没错了……
作者: IamI    时间: 2009-1-2 00:48
以下引用风花雪月于2009-1-1 16:43:48的发言:

http://rpg.blue/web/htm/news816.htm这次没错了……

KaMiSaMa的吗……总算是找到了一点价值。
作者: 远恒    时间: 2009-1-2 02:08
不是的..我是说改我那个脚本{/dk}
作者: 后知后觉    时间: 2009-1-2 04:28
找到Scene_Map
在 def main 的下面增加一行
@status_window = Window_BattleStatus.new
然后在35行左右有一句  @spriteset.dispose
在下面增加一行 @status_window.dispose
然后找到58行左右能看到  $game_screen.update
在下面增加一行 @status_window.update
这样就可以了,估计你会后悔要这样的效果的= =||b [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: 远恒    时间: 2009-1-2 07:36
太太太太太感谢您了!{/dk}




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