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

Project1

 找回密码
 注册会员
搜索

请教一个关于血条

查看数: 1821 | 评论数: 14 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2009-11-10 13:58

正文摘要:

本帖最后由 elpplp 于 2009-11-10 14:01 编辑 怎么样才可以做到主角队伍的血和敌人显示的血一样。 我只的是横板模式下~ 还有就是怎么把血条弄在人物图片的正上方呢?谢谢 如下图~ 望高人指点。。。跪地求解。。 ...

回复

elpplp 发表于 2009-11-11 15:25:16
提示: 作者被禁止或删除 内容自动屏蔽
夏季冰川 发表于 2009-11-11 02:11:13
本帖最后由 夏季冰川 于 2009-11-11 13:15 编辑

89-125行:文字坐标(就是那个HP,SP文字的位置)
164-194行:血条坐标
那个问题可以解决。
最简单的办法就是用指令化图标:
  1. #==========================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==========================================================================

  4. module Momo_IconCommand
  5.   # 图标名称设定
  6.   ATTACK_ICON_NAME = "1-攻击" # 攻撃
  7.   SKILL_ICON_NAME = "1-法术"   # 特技
  8.   GUARD_ICON_NAME = "1-防御"  # 防御
  9.   ITEM_ICON_NAME = "1-道具"     # 物品
  10.   # X坐标修正
  11.   X_PLUS = 60
  12.   # Y坐标修正
  13.   Y_PLUS = -60
  14.   # 选择时图标的动作
  15.   # 0:静止 1:放大
  16.   SELECT_TYPE = 1
  17.   # 闪烁时光芒的颜色
  18.   FLASH_COLOR = Color.new(255, 255, 255, 128)
  19.   # 闪烁时间
  20.   FLASH_DURATION = 10
  21.   # 闪烁间隔
  22.   FLASH_INTERVAL = 20
  23.   # 是否写出文字的名称
  24.   COM_NAME_DROW = true
  25.   # 文字名称是否移动
  26.   COM_NAME_MOVE = true
  27.   # 文字内容
  28.   ATTACK_NAME = "攻击"    # 攻击
  29.   SKILL_NAME = "法术"   # 特技
  30.   GUARD_NAME = "防御"     # 防御
  31.   ITEM_NAME = "道具"  # 物品
  32.   # 文字颜色
  33.   COM_NAME_COLOR = Color.new(255, 255, 255, 255)
  34.   # 文字坐标修正
  35.   COM_NAME_X_PLUS = 0
  36.   COM_NAME_Y_PLUS = 0
  37. end

  38. class Window_CommandIcon < Window_Selectable
  39.   attr_accessor :last_index
  40.   #------------------------------------------------------------------------
  41.   # ● オブジェクト初期化
  42.   #------------------------------------------------------------------------
  43.   def initialize(x, y, commands)
  44.     super(x, y, 32, 32)
  45.     # ウィンドウスキンに空文字列を指定してウィンドウを描画しないようにする
  46.     self.windowskin = RPG::Cache.windowskin("")
  47.     @item_max = commands.size
  48.     @commands = commands
  49.     @column_max = 1
  50.     @index = 0
  51.     @last_index = nil
  52.     @name_sprite = nil
  53.     @sprite = []
  54.     refresh
  55.   end
  56.   def dispose
  57.     super
  58.     for sprite in @sprite
  59.       sprite.dispose unless sprite.nil?
  60.     end
  61.     @name_sprite.dispose unless @name_sprite.nil?
  62.   end
  63.   #------------------------------------------------------------------------
  64.   # ● リフレッシュ
  65.   #------------------------------------------------------------------------
  66.   def refresh
  67.     @name_sprite.dispose unless @name_sprite.nil?
  68.     for sprite in @sprite
  69.       sprite.dispose unless sprite.nil?
  70.     end
  71.     @name_sprite = nil
  72.     draw_com_name if Momo_IconCommand::COM_NAME_DROW
  73.     @sprite = []
  74.     for i in 0...@item_max
  75.       draw_item(i)
  76.     end
  77.   end
  78.   #------------------------------------------------------------------------
  79.   # ● 項目の描画
  80.   #------------------------------------------------------------------------
  81.   def draw_item(index)
  82.     @sprite[index] = Sprite_Icon.new(nil, @commands[index])
  83.     @sprite[index].z = self.z + 1
  84.   end
  85.   def draw_com_name
  86.     @name_sprite = Sprite_Comm_Name.new(nil, get_com_name)
  87.    
  88.   end
  89.   
  90.   # 更新
  91.   def update
  92.     super
  93.     icon_update
  94.     com_name_update if Momo_IconCommand::COM_NAME_DROW
  95.     if move_index?
  96.       @last_index = self.index
  97.     end
  98.   end
  99.   # アイコンの更新
  100.   def icon_update
  101.     for i in [email protected]
  102.       @sprite[i].active = (self.index == i)
  103.       @sprite[i].x = self.x + 0
  104.       @sprite[i].y = self.y + 24*i
  105.       @sprite[i].z = (self.index == i) ? self.z + 2 : self.z + 1
  106.       @sprite[i].visible = self.visible
  107.       @sprite[i].update
  108.     end
  109.   end
  110.   # コマンドネームの更新
  111.   def com_name_update
  112.     if move_index?
  113.       @name_sprite.name = get_com_name
  114.     end
  115.     @name_sprite.x = self.x - 12 + Momo_IconCommand::COM_NAME_X_PLUS
  116.     @name_sprite.y = self.y - 40 + Momo_IconCommand::COM_NAME_Y_PLUS
  117.     @name_sprite.z = self.z + 1
  118.     @name_sprite.active = self.active
  119.     @name_sprite.visible = self.visible
  120.     @name_sprite.update
  121.   end
  122.   def get_com_name
  123.     make_name_set if @name_set.nil?
  124.     name = @name_set[self.index]
  125.     name = "" if name.nil?
  126.     return name
  127.   end
  128.   def make_name_set
  129.     @name_set = []
  130.     @name_set[0] = Momo_IconCommand::ATTACK_NAME
  131.     @name_set[1] = Momo_IconCommand::SKILL_NAME
  132.     @name_set[2] = Momo_IconCommand::GUARD_NAME
  133.     @name_set[3] = Momo_IconCommand::ITEM_NAME
  134.   end
  135.   def move_index?
  136.     return self.index != @last_index
  137.   end
  138.   def need_reset
  139.     @name_sprite.need_reset = true if Momo_IconCommand::COM_NAME_DROW
  140.   end
  141. end

  142. # アイコン用スプライト
  143. class Sprite_Icon < Sprite
  144.   attr_accessor :active
  145.   attr_accessor :icon_name
  146.   #------------------------------------------------------------------------
  147.   # ● オブジェクト初期化
  148.   #------------------------------------------------------------------------
  149.   def initialize(viewport, icon_name)
  150.     super(viewport)
  151.     @icon_name = icon_name
  152.     @last_icon = @icon_name
  153.     @count = 0
  154.     self.bitmap = RPG::Cache.icon(@icon_name)
  155.     self.ox = self.bitmap.width / 2
  156.     self.oy = self.bitmap.height / 2
  157.     @active = false
  158.   end
  159.   #------------------------------------------------------------------------
  160.   # ● 解放
  161.   #------------------------------------------------------------------------
  162.   def dispose
  163.     if self.bitmap != nil
  164.       self.bitmap.dispose
  165.     end
  166.     super
  167.   end
  168.   #------------------------------------------------------------------------
  169.   # ● フレーム更新
  170.   #------------------------------------------------------------------------
  171.   def update
  172.     super
  173.     if @icon_name != @last_icon
  174.       @last_icon = @icon_name
  175.       self.bitmap = RPG::Cache.icon(@icon_name)
  176.     end
  177.     if @active
  178.       @count += 1
  179.       case Momo_IconCommand::SELECT_TYPE
  180.       when 0
  181.         icon_flash
  182.       when 1
  183.         icon_zoom
  184.       end
  185.       @count = 0 if @count == 20
  186.     else
  187.       icon_reset
  188.     end
  189.   end
  190.   def icon_flash
  191.     if @count % Momo_IconCommand::FLASH_INTERVAL == 0 or @count == 1
  192.       self.flash(Momo_IconCommand::FLASH_COLOR, Momo_IconCommand::FLASH_DURATION)
  193.     end
  194.   end
  195.   def icon_zoom
  196.     case @count
  197.     when 1..10
  198.       zoom = 1.0  + @count / 10.0
  199.     when 11..20
  200.       zoom = 2.0  - (@count - 10) / 10.0
  201.     end
  202.     self.zoom_x = zoom
  203.     self.zoom_y = zoom
  204.   end
  205.   def icon_reset
  206.     @count = 0
  207.     self.zoom_x = 1.0
  208.     self.zoom_y = 1.0
  209.   end
  210. end

  211. # コマンドネーム用スプライト
  212. class Sprite_Comm_Name < Sprite
  213.   attr_accessor :active
  214.   attr_accessor :name
  215.   attr_accessor :need_reset
  216.   #------------------------------------------------------------------------
  217.   # ● オブジェクト初期化
  218.   #------------------------------------------------------------------------
  219.   def initialize(viewport, name)
  220.     super(viewport)
  221.     @name = name
  222.     @last_name = nil
  223.     @count = 0
  224.     @x_plus = 0
  225.     @opa_plus = 0
  226.     @need_reset = false
  227.     @active = false
  228.     self.bitmap = Bitmap.new(160, 32)
  229.   end
  230.   #------------------------------------------------------------------------
  231.   # ● 解放
  232.   #------------------------------------------------------------------------
  233.   def dispose
  234.     if self.bitmap != nil
  235.       self.bitmap.dispose
  236.     end
  237.     super
  238.   end
  239.   #------------------------------------------------------------------------
  240.   # ● フレーム更新
  241.   #------------------------------------------------------------------------
  242.   def update
  243.     super
  244.     if @active
  245.       if need_reset?
  246.         @need_reset = false
  247.         @last_name = @name
  248.         text_reset
  249.       end
  250.       move_text if Momo_IconCommand::COM_NAME_MOVE
  251.     end
  252.   end
  253.   def move_text
  254.     @count += 1
  255.     @x_plus = [@count * 8, 80].min
  256.     self.x = self.x - 80 + @x_plus
  257.     self.opacity = @count * 25
  258.   end
  259.   def text_reset
  260.     @count = 0
  261.     @x_plus = 0
  262.     self.bitmap.clear
  263.     self.bitmap.font.color = Momo_IconCommand::COM_NAME_COLOR
  264.     self.bitmap.draw_text(0, 0, 160, 32, @name)
  265.   end
  266.   def need_reset?
  267.     return (@name != @last_name or @need_reset)
  268.   end
  269. end

  270. class Scene_Battle
  271.   #------------------------------------------------------------------------
  272.   # ● プレバトルフェーズ開始
  273.   #------------------------------------------------------------------------
  274.   alias scene_battle_icon_command_start_phase1 start_phase1
  275.   def start_phase1
  276.     com1 = Momo_IconCommand::ATTACK_ICON_NAME
  277.     com2 = Momo_IconCommand::SKILL_ICON_NAME
  278.     com3 = Momo_IconCommand::GUARD_ICON_NAME
  279.     com4 = Momo_IconCommand::ITEM_ICON_NAME
  280.     @actor_command_window = Window_CommandIcon.new(0, 0, [com1, com2, com3, com4])
  281.     @actor_command_window.y = 160
  282.     @actor_command_window.back_opacity = 160
  283.     @actor_command_window.active = false
  284.     @actor_command_window.visible = false
  285.     @actor_command_window.update
  286.     scene_battle_icon_command_start_phase1
  287.   end
  288.   #------------------------------------------------------------------------
  289.   # ● アクターコマンドウィンドウのセットアップ
  290.   #------------------------------------------------------------------------
  291.   alias scene_battle_icon_command_phase3_setup_command_window phase3_setup_command_window
  292.   def phase3_setup_command_window
  293.     scene_battle_icon_command_phase3_setup_command_window
  294.     # アクターコマンドウィンドウの位置を設定
  295.     @actor_command_window.x = command_window_actor_x(@actor_index)
  296.     @actor_command_window.y = command_window_actor_y(@actor_index)
  297.     @actor_command_window.need_reset
  298.   end
  299.   def command_window_actor_x(index)
  300.     $game_party.actors[index].screen_x + Momo_IconCommand::X_PLUS
  301.   end
  302.   def command_window_actor_y(index)
  303.     $game_party.actors[index].screen_y + Momo_IconCommand::Y_PLUS
  304.   end
  305. end

  306. #==========================================================================
  307. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  308. #==========================================================================
复制代码
如果要调整那些框框也可以,但现在我手上没RM,晚上再看看。
elpplp 发表于 2009-11-10 20:17:26
提示: 作者被禁止或删除 内容自动屏蔽
elpplp 发表于 2009-11-10 16:11:05
提示: 作者被禁止或删除 内容自动屏蔽
elpplp 发表于 2009-11-10 15:54:34
提示: 作者被禁止或删除 内容自动屏蔽
夏季冰川 发表于 2009-11-10 15:53:04
我这上传速度就像渣一样,算了,我把脚本贴出来,坐标只能你自己调了。

首先,给战斗背景换张大图片(640*480)。

怪物血量显示41-42行替换成:
  1.      x = @battler.screen_x - width / 2
  2.      y = @battler.screen_y - height + PLAN_HPSP_DRAW::DRAW_Y
复制代码
然后以下脚本插入main之前,放到最后:
  1. # ————————————————————————————————————
  2. # 本脚本来自http://rpg.blue/web/,转载请保留此信息
  3. # ————————————————————————————————————
  4. #==============================================================================
  5. # ■ Window_Base
  6. #------------------------------------------------------------------------------
  7. #  游戏中全部窗口的超级类。
  8. #==============================================================================

  9. class Window_Base < Window
  10. #--------------------------------------------------------------------------
  11. # ● 描绘 HP
  12. #     actor : 角色
  13. #     x     : 描画目标 X 坐标
  14. #     y     : 描画目标 Y 坐标
  15. #     width : 描画目标的宽
  16. #--------------------------------------------------------------------------
  17. def draw_actor_hp1(actor, x, y, width = 72)
  18.    # 描绘字符串 "HP"
  19.    self.contents.font.color = system_color
  20.    self.contents.draw_text(x, y, 24, 24, $data_system.words.hp)
  21.    # 计算描绘 MaxHP 所需的空间
  22.    if width - 24 >= 32
  23.      hp_x = x + 32# + width - 24
  24.    end
  25.    # 描绘 HP
  26.    self.contents.font.color = actor.hp == 0 ? knockout_color :
  27.      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  28.    self.contents.draw_text(hp_x, y, 32, 24, actor.hp.to_s, 2)
  29. end


  30. #--------------------------------------------------------------------------
  31. # ● 描绘 SP
  32. #     actor : 角色
  33. #     x     : 描画目标 X 坐标
  34. #     y     : 描画目标 Y 坐标
  35. #     width : 描画目标的宽
  36. #--------------------------------------------------------------------------
  37. def draw_actor_sp1(actor, x, y, width = 72)
  38.    # 描绘字符串 "SP"
  39.    self.contents.font.color = system_color
  40.    self.contents.draw_text(x, y, 24, 24, $data_system.words.sp)
  41.    # 计算描绘 MaxSP 所需的空间
  42.    if width - 24 >= 32
  43.      sp_x = x + 32# + width - 24
  44.    end
  45.    # 描绘 SP
  46.    self.contents.font.color = actor.sp == 0 ? knockout_color :
  47.      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  48.    self.contents.draw_text(sp_x, y, 32, 24, actor.sp.to_s, 2)
  49. end
  50. end

  51. #==============================================================================
  52. # ■ Window_BattleStatus
  53. #------------------------------------------------------------------------------
  54. #  显示战斗画面同伴状态的窗口。
  55. #==============================================================================

  56. class Window_BattleStatus < Window_Base
  57. #--------------------------------------------------------------------------
  58. # ● 初始化对像
  59. #--------------------------------------------------------------------------
  60. #$data_system_level_up_me = "Audio/ME/升级音乐"
  61. def initialize
  62.    super(0, 0, 640, 480)
  63.    self.contents = Bitmap.new(width - 10, height - 32)
  64.    self.opacity = 0
  65.    @level_up_flags = [false, false, false, false]
  66.    refresh
  67. end
  68. #--------------------------------------------------------------------------
  69. # ● 释放
  70. #--------------------------------------------------------------------------
  71. def dispose
  72.    super
  73. end
  74. #--------------------------------------------------------------------------
  75. # ● 设置升级标志
  76. #     actor_index : 角色索引
  77. #--------------------------------------------------------------------------
  78. def level_up(actor_index)
  79.    @level_up_flags[actor_index] = true
  80. end
  81. #--------------------------------------------------------------------------
  82. # ● 刷新
  83. #--------------------------------------------------------------------------
  84. def refresh
  85.    self.contents.clear
  86.    @item_max = $game_party.actors.size
  87.     for i in 0...$game_party.actors.size
  88.      actor = $game_party.actors[i]
  89.      case i
  90.        when 0
  91.         x = 500
  92.         y = 100
  93.        when 1
  94.         x = 500
  95.         y = 140
  96.        when 2
  97.         x = 500
  98.         y = 180
  99.        when 3
  100.         x = 500
  101.         y = 220
  102.         when 4
  103.         x = 500
  104.         y = 260
  105.         when 5
  106.         x = 500
  107.         y = 300
  108.         when 6
  109.         x = 500
  110.         y = 340
  111.         when 7
  112.         x = 500
  113.         y = 380
  114.         when 8
  115.         x = 500
  116.         y = 420
  117.          when 9
  118.         x = 500
  119.         y = 460
  120.       end
  121.      if @level_up_flags[i]
  122.        self.contents.font.color = normal_color
  123.        self.contents.draw_text(x, y, 80, 24, "LEVEL UP!")
  124.        Audio.me_stop
  125. #        Audio.me_play($data_system_level_up_me)
  126.      else
  127.      draw_actor_hp1(actor, x-15, y-15, 80)
  128.      draw_actor_sp1(actor, x-15, y+5, 80)
  129.     end
  130.    end
  131. end

  132. #--------------------------------------------------------------------------
  133. # ● 刷新画面
  134. #--------------------------------------------------------------------------
  135. def update
  136.    super
  137. end
  138. end





  139. #==============================================================================
  140. # ■ Window_BattleStatus
  141. #==============================================================================
  142. class Window_BattleStatus < Window_Base
  143. #--------------------------------------------------------------------------
  144. # ● 初始化
  145. #--------------------------------------------------------------------------
  146. alias xrxs_bp2_refresh refresh
  147. def refresh
  148.    xrxs_bp2_refresh
  149.    @item_max = $game_party.actors.size
  150.     for i in 0...$game_party.actors.size
  151.      actor = $game_party.actors[i]
  152.      case i
  153.        when 0
  154.         x = 500
  155.         y = 100
  156.        when 1
  157.         x = 500
  158.         y = 140
  159.        when 2
  160.         x = 500
  161.         y = 180
  162.        when 3
  163.         x = 500
  164.         y = 220
  165.         when 4
  166.         x = 500
  167.         y = 260
  168.         when 5
  169.         x = 500
  170.         y = 300
  171.         when 6
  172.         x = 500
  173.         y = 340
  174.         when 7
  175.         x = 500
  176.         y = 380
  177.         when 8
  178.         x = 500
  179.         y = 420
  180.          when 9
  181.         x = 500
  182.         y = 460
  183.       end
  184.      draw_actor_hp_meter(actor, x, y, 50)
  185.      draw_actor_sp_meter(actor, x, y + 8, 50)
  186.   end
  187. end
  188. end
  189. #==============================================================================
  190. # ■ Window_Base
  191. #==============================================================================
  192. class Window_Base < Window
  193. #--------------------------------------------------------------------------
  194. # ● HP描画
  195. #--------------------------------------------------------------------------
  196. def draw_actor_hp_meter(actor, x, y, width = 156, type = 0)
  197.    if type == 1 and actor.hp == 0
  198.      return
  199.    end
  200.    self.contents.font.color = system_color
  201.    self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 25))
  202.    w = width * actor.hp / actor.maxhp
  203.    self.contents.fill_rect(x, y+28, w,1, Color.new(255, 96, 96, 255))
  204.    self.contents.fill_rect(x, y+29, w,1, Color.new(255, 0, 0, 255))
  205.    self.contents.fill_rect(x, y+30, w,1, Color.new(128, 0, 0, 255))
  206.    self.contents.fill_rect(x, y+31, w,1, Color.new(0, 0, 0, 255))
  207. end

  208. #--------------------------------------------------------------------------
  209. # ● SP描画
  210. #--------------------------------------------------------------------------
  211. def draw_actor_sp_meter(actor, x, y, width = 156, type = 0)
  212.    if type == 1 and actor.hp == 0
  213.      return
  214.    end
  215.    self.contents.font.color = system_color
  216.    self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  217.    w = width * actor.sp / actor.maxsp
  218.    self.contents.fill_rect(x, y+28, w,1, Color.new(128, 255, 255, 255))
  219.    self.contents.fill_rect(x, y+29, w,1, Color.new(0, 255, 255, 255))
  220.    self.contents.fill_rect(x, y+30, w,1, Color.new(0, 192, 192, 255))
  221.    self.contents.fill_rect(x, y+31, w,1, Color.new(0, 128, 128, 255))
  222. end
  223. end
复制代码
elpplp 发表于 2009-11-10 15:23:03
提示: 作者被禁止或删除 内容自动屏蔽
elpplp 发表于 2009-11-10 15:18:33
提示: 作者被禁止或删除 内容自动屏蔽
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-12-28 04:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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