Project1
标题:
关于伤害值显示的问题
[打印本页]
作者:
njx937
时间:
2008-10-14 08:05
标题:
关于伤害值显示的问题
#伤害值美化脚本 Beside--------------------------------------------------------
#66RPG 转载请保留此信息--------------------------------------------------------
class Game_Battler
attr_accessor :hp_damage
attr_accessor :mp_damage
attr_accessor :damage_pop
attr_accessor :critical
alias ini initialize
def initialize
ini
@damage_pop = false
end
end
class Sprite_Base
def initialize(viewport = nil)
super(viewport)
@use_sprite = true # 活动块使用的标志
@animation_duration = 0 # 动画剩余时间
@_damage_duration = 0
end
def update
super
if @animation != nil
@animation_duration -= 1
if @animation_duration % 4 == 0
update_animation
end
end
@@animations.clear
if @_damage_duration > 0
@_damage_duration -= 1
case @_damage_duration
when 38..39
@_damage_sprite.y -= 4
when 36..37
@_damage_sprite.y -= 2
when 34..35
@_damage_sprite.y += 2
when 28..33
@_damage_sprite.y += 4
end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
if @_damage_duration == 0
dispose_damage
end
end
end
def damage(value, critical)
dispose_damage # 释放伤害
if value.is_a?(Numeric) # 如果伤害值是数值
damage_string = value.abs.to_s # 绝对值转为字符串
else
damage_string = value.to_s # 转为字符串
end
bitmap = Bitmap.new(162, 64) # 初始化位图
bitmap.font.name = "Arial Black"
bitmap.font.size = 23
if value.is_a?(Numeric)
damage_array = damage_string.scan(/./) # 分割伤害值字符串
damage_x = 81 - damage_string.size * 9
if value < 0 # 伤害值为负的情况下
rect_y = 32 # 调用回复数字表
else
rect_y = 0 # 调用伤害数字表
end
for char in damage_array # 循环伤害值字符串
number = char.to_i
bitmap.blt(damage_x, 32, Cache.picture("Damage1"), Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18 # 后移一位
end
else
if value == "Evaded"
bitmap.blt(36, 28, Cache.picture("Damage1"), Rect.new(0, 96, 84, 32))
else
# 显示未击中图画
bitmap.blt(36, 28, Cache.picture("Damage1"), Rect.new(90, 64, 90, 32))
end
end
if critical # 会心一击标志打开的情况
# 显示会心一击图画
bitmap.blt(36, 0, Cache.picture("Damage1"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = Sprite_Base.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 81
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy
@_damage_sprite.z = 3000
@_damage_duration = 40
end
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
end
class Sprite_Battler
alias setup_new_effect_66RPG setup_new_effect
def setup_new_effect
setup_new_effect_66RPG
if @battler.damage_pop
if @battler.hp_damage != 0 and @battler.hp_damage != nil
damage(@battler.hp_damage, @battler.critical)
end
if @battler.mp_damage != 0 and @battler.mp_damage != nil
damage(@battler.mp_damage, @battler.critical)
end
if @battler.missed
damage("Miss", @battler.critical)
end
if @battler.evaded
damage("Evaded", @battler.critical)
end
@battler.damage_pop = false
end
end
end
class Scene_Battle
def display_action_effects(target, obj = nil)
unless target.skipped
line_number = @message_window.line_number
wait(10)
target.damage_pop = true if target.is_a?(Game_Enemy)
display_critical(target, obj)
display_damage(target, obj)
display_state_changes(target, obj)
@status_window.refresh
if line_number == @message_window.line_number
display_failure(target, obj) unless target.states_active?
end
if line_number != @message_window.line_number
wait(30)
end
@message_window.back_to(line_number)
end
end
end
复制代码
我用的是这个伤害显示的
然后是下面那个显血条的
问题是:每次打完,对方血条都没了才显伤害(就是显示伤害太慢了),可以加快吗?
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘 HP
# enemy : 角色
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
# width : 宽
#--------------------------------------------------------------------------
def draw_enemy_hp(enemy, x, y, width = 65)
draw_actor_hp_gauge(enemy, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
self.contents.font.color = hp_color(enemy)
xr = x + width
self.contents.draw_text(xr - 40, y, 40, WLH, enemy.hp, 2)
end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
# 战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视、活动块状态自动变化。
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
WHITEN = 1 # 白色闪烁 (开始行动)
BLINK = 2 # 闪烁 (伤害)
APPEAR = 3 # 出现 (出现、复活)
DISAPPEAR = 4 # 消失 (逃走)
COLLAPSE = 5 # 崩溃 (不能战斗)
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# ● 初始化对象
# viewport : 视区
# battler : 战斗者 (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@effect_type = 0 # 效果种类
@effect_duration = 0 # 效果剩余时间
if @battler.is_a?(Game_Enemy)
width = 65 + 32
height = 24 + 32
x = @battler.screen_x - width/2
y = @battler.screen_y - height/2
@enemy_hp_window = Window_Base.new(x, y, width, height)
@enemy_hp_window.opacity = 0
@enemy_hp_window.contents = Bitmap.new(width - 32, height - 32)
@enemy_hp_window.draw_enemy_hp(@battler, 0, 0, 65)
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
@enemy_hp_window.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if @battler == nil
self.bitmap = nil
else
@use_sprite = @battler.use_sprite?
if @use_sprite
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
update_battler_bitmap
end
setup_new_effect
update_effect
if @enemy_hp_window != nil and @old_hp != @battler.hp
@enemy_hp_window.contents.clear
@enemy_hp_window.draw_enemy_hp(@battler, 0, 0, 65)
@old_hp = @battler.hp
end
end
end
end
复制代码
[LINE]1,#dddddd[/LINE]
此贴于 2008-10-16 13:38:04 被版主八云紫提醒,请楼主看到后对本贴做出回应。
[LINE]1,#dddddd[/LINE]
本贴由论坛斑竹八云紫结贴,如楼主认为问题未解决,请重新将此贴编辑为“有事请教”,并回帖叙述疑点即可~ ^-^
唉,还是没人会……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1