赞 | 123 |
VIP | 13 |
好人卡 | 16 |
积分 | 194 |
经验 | 38692 |
最后登录 | 2024-11-10 |
在线时间 | 3097 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 19388
- 在线时间
- 3097 小时
- 注册时间
- 2013-1-11
- 帖子
- 1290
|
本帖最后由 张咚咚 于 2017-6-24 19:27 编辑
class Scene_Battle < Scene_Base alias new_start start def start new_start @damage_ = Sprite_Damage.new end alias new_terminate terminate def terminate new_terminate @damage_.dispose end alias new_update_basic update_basic def update_basic(main = false) new_update_basic(main) @damage_.update end alias new_display_hp_damage display_hp_damage def display_hp_damage(target, obj = nil) @damage_.start_damage(target.screen_x, target.screen_y - 30, target.hp_damage, "") new_display_hp_damage(target, obj) end end class Sprite_Damage < Sprite_Base def initialize super(Viewport.new(0, 0, 544, 416)) @xxx = 0 @yyy = 0 @_damage_duration = 0 end def start_damage(xxx, yyy, value, damage_type) dispose @xxx = xxx @yyy = yyy if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "方正粗圆简体" #暴击 if damage_type == "Critical" #设置数值 bitmap.font.size = 22 bitmap.font.color.set(180, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) bitmap.font.color.set(255, 0, 0) bitmap.draw_text(0, 12, 160, 36, damage_string, 1) #设置文本 bitmap.font.size = 18 bitmap.font.color.set(180, 0, 0) bitmap.draw_text(-1, -1, 160, 20, "暴击", 1) bitmap.draw_text(+1, -1, 160, 20, "暴击", 1) bitmap.draw_text(-1, +1, 160, 20, "暴击", 1) bitmap.draw_text(+1, +1, 160, 20, "暴击", 1) bitmap.font.color.set(255, 0, 0) bitmap.draw_text(0, 0, 160, 20, "暴击", 1) #伤害 elsif damage_type == "" bitmap.font.size = 22 if value.is_a?(Numeric) if value <= 0 bitmap.font.color.set(0, 180, 0) else bitmap.font.color.set(180, 0, 0) end else bitmap.font.color.set(0, 0, 0) end bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) if value <= 0 bitmap.font.color.set(0, 255, 0) else bitmap.font.color.set(255, 0, 0) end else bitmap.font.color.set(255, 255, 255) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) end @_damage_sprite = ::Sprite.new(self.viewport) @_damage_sprite.bitmap = bitmap @_damage_sprite.ox = 80 @_damage_sprite.oy = 20 @_damage_sprite.x = self.x @_damage_sprite.y = self.y - self.oy @_damage_sprite.z = 3000 @_damage_duration = 40 update end def update if @_damage_duration > 0 @_damage_sprite.x = @xxx @_damage_sprite.y = @yyy @_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 dispose() if @_damage_duration == 0 end end def dispose if @_damage_sprite != nil @_damage_sprite.bitmap.dispose @_damage_sprite.dispose @_damage_sprite = nil @_damage_duration = 0 end end end
class Scene_Battle < Scene_Base
alias new_start start
def start
new_start
@damage_ = Sprite_Damage.new
end
alias new_terminate terminate
def terminate
new_terminate
@damage_.dispose
end
alias new_update_basic update_basic
def update_basic(main = false)
new_update_basic(main)
@damage_.update
end
alias new_display_hp_damage display_hp_damage
def display_hp_damage(target, obj = nil)
@damage_.start_damage(target.screen_x, target.screen_y - 30, target.hp_damage, "")
new_display_hp_damage(target, obj)
end
end
class Sprite_Damage < Sprite_Base
def initialize
super(Viewport.new(0, 0, 544, 416))
@xxx = 0
@yyy = 0
@_damage_duration = 0
end
def start_damage(xxx, yyy, value, damage_type)
dispose
@xxx = xxx
@yyy = yyy
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "方正粗圆简体"
#暴击
if damage_type == "Critical"
#设置数值
bitmap.font.size = 22
bitmap.font.color.set(180, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
bitmap.font.color.set(255, 0, 0)
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
#设置文本
bitmap.font.size = 18
bitmap.font.color.set(180, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "暴击", 1)
bitmap.draw_text(+1, -1, 160, 20, "暴击", 1)
bitmap.draw_text(-1, +1, 160, 20, "暴击", 1)
bitmap.draw_text(+1, +1, 160, 20, "暴击", 1)
bitmap.font.color.set(255, 0, 0)
bitmap.draw_text(0, 0, 160, 20, "暴击", 1)
#伤害
elsif damage_type == ""
bitmap.font.size = 22
if value.is_a?(Numeric)
if value <= 0
bitmap.font.color.set(0, 180, 0)
else
bitmap.font.color.set(180, 0, 0)
end
else
bitmap.font.color.set(0, 0, 0)
end
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric)
if value <= 0
bitmap.font.color.set(0, 255, 0)
else
bitmap.font.color.set(255, 0, 0)
end
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy
@_damage_sprite.z = 3000
@_damage_duration = 40
update
end
def update
if @_damage_duration > 0
@_damage_sprite.x = @xxx
@_damage_sprite.y = @yyy
@_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
dispose() if @_damage_duration == 0
end
end
def dispose
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
end
自己找的一个地图显示伤害脚本改了改,插入到main之前,好像没什么问题
|
评分
-
查看全部评分
|