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

Project1

 找回密码
 注册会员
搜索
查看: 3250|回复: 1

[已经解决] 战斗界面显示敌人血量,不显示数量,只显示血条。

[复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
25 小时
注册时间
2015-3-15
帖子
12
发表于 2015-10-24 12:19:14 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 taroxd 于 2015-10-24 12:50 编辑

怎么在战斗模式下显示敌人的生命值?不显示数量,但是显示血条。

原来的脚本:
RUBY 代码复制
  1. class Window_Base < Window
  2.   #--------------------------------------------------------------------------
  3.   # ● 描绘敌人HP
  4.   #--------------------------------------------------------------------------
  5.   def draw_enemy_hp(enemy, x, y, width = 80)
  6.     draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
  7.     self.contents.font.color = system_color
  8.     self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
  9.     self.contents.font.color = hp_color(enemy)
  10.     self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
  11.     #一个数字占16像素
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 绘制敌人MP
  15.   #--------------------------------------------------------------------------
  16.   def draw_enemy_mp(enemy, x, y, width = 80)
  17.     draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
  18.     self.contents.font.color = system_color
  19.     self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
  20.     self.contents.font.color = mp_color(enemy)
  21.     self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  22.   end
  23. end
  24. #==============================================================================
  25. # ■ Sprite_Battler
  26. #------------------------------------------------------------------------------
  27. #  战斗显示用活动块。Game_Battler 类的实例监视、
  28. # 活动块的状态的监视、活动块状态自动变化。
  29. #==============================================================================
  30.  
  31. class Sprite_Battler < Sprite_Base
  32.   #--------------------------------------------------------------------------
  33.   # ● 初始化对象
  34.   #     viewport : 视区
  35.   #     battler  : 战斗者 (Game_Battler)
  36.   #--------------------------------------------------------------------------
  37.   def initialize(viewport, battler = nil)
  38.     super(viewport)
  39.     @battler = battler
  40.     @battler_visible = false
  41.     @effect_type = nil      
  42.     @effect_duration = 0   
  43.     if @battler.is_a?(Game_Enemy)
  44.       width = 24 + 80 #边距12*2+血条的长度(在draw_enemy_hp中定义)
  45.       height = 24 + 24*2 #边距12*2+line_height*2
  46.       x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置
  47.       y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框
  48.       @enemy_hpmp_window = Window_Base.new(x, y, width, height)
  49.       @enemy_hpmp_window.opacity = 0
  50.       @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框
  51.       @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  52.       @old_hp = -1
  53.       @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  54.       @old_mp = -1
  55.     end
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 释放
  59.   #--------------------------------------------------------------------------
  60.   def dispose
  61.     if self.bitmap != nil
  62.       self.bitmap.dispose
  63.       @enemy_hpmp_window.dispose
  64.     end
  65.     super
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 更新画面
  69.   #--------------------------------------------------------------------------
  70.   def update
  71.     super
  72.     if @battler == nil
  73.       self.bitmap = nil
  74.     else
  75.       @use_sprite = @battler.use_sprite?
  76.       if @use_sprite
  77.         update_bitmap
  78.         update_origin
  79.         update_position
  80.       end
  81.       setup_new_effect
  82.       setup_new_animation
  83.       update_effect
  84.       if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
  85.         if @battler.hp == 0
  86.           @enemy_hpmp_window.hide
  87.         else
  88.           @enemy_hpmp_window.contents.clear
  89.           @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  90.           @old_hp = @battler.hp
  91.           @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  92.           @old_mp = @battler.mp
  93.           @enemy_hpmp_window.show #怪物死后再被复活
  94.         end #if battler.hp == 0
  95.       end
  96.     end #if @battler == nil
  97.   end
  98.  
  99. end


求帮下忙→_→   

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2207
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

发表于 2015-10-24 12:49:59 | 显示全部楼层
已为你加上代码框。删掉7~11行即可

点评

谢谢  发表于 2015-10-24 13:53

评分

参与人数 1星屑 +150 收起 理由
VIPArcher + 150 认可答案

查看全部评分

回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-3-29 22:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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