仙剑之十里坡
标题:
伤害美化~使用方法不解释
[打印本页]
作者:
BlackFeather
时间:
2010-3-27 18:39
标题:
伤害美化~使用方法不解释
本帖最后由 白爪子的黑猫 于 2010-3-26 22:40 编辑
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ============================================================================
# 伤害效果美化 v1.0 by SailCat
# ============================================================================
# 脚本使用说明:
# 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下
# 2.Damage.png文件的格式:
# 大小为180 x 96
# (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32
# (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32
# (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32
# (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32
# ============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# ● 伤害值描画
#--------------------------------------------------------------------------
def damage(value, critical, sp_damage = false)
# 释放伤害
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 = 32
# 伤害值是数值的情况下
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
# 显示伤害数字
if sp_damage
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damagesp"),
Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18
else
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18
end
end
# 伤害值不是数值的情况
else
# 如果伤害值不是 Miss
unless value == "Miss"
# 系统默认描画字符串
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
# Miss 的情况下
else
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
end
end
# 会心一击标志打开的情况
if critical
# 显示会心一击图画
bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = ::Sprite.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 / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
欢迎光临 仙剑之十里坡 (http://palslp.com/BBS/)
Powered by Discuz! X2.5