#============================================================================== # ■ Sprite_Mini_Hp_Bar #------------------------------------------------------------------------------ # バトル画面でダメージ時に表示する小型のHPバーです。 #============================================================================== class Sprite_Mini_Hp_Bar < Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport, battler, character) super(viewport) self.bitmap = Cache.system("status_bar_hpsp_mini_red") @max_hp = battler.mhp @hp = battler.ori_hp_bar @damage = battler.result.hp_damage @show_fast = false self.x = character.screen_x self.y = character.screen_y self.z = character.screen_z + 312 @wait = 25 @sprite_bar_green = Sprite.new(viewport) @sprite_bar_green.bitmap = Cache.system("status_bar_hpsp_mini_green") @sprite_bar_green.x = self.x + 2 @sprite_bar_green.y = self.y + 2 @sprite_bar_green.z = self.z + 32 if @damage == 0 self.visible = false @sprite_bar_green.visible = false end update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose @sprite_bar_green.dispose super end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def show_fast(flag) @show_fast = flag end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @wait = 0 if @wait < 0 now_hp = @hp - @damage * (25 - @wait) / 25 cx = (now_hp * 100 / @max_hp) / 4 cx = 25 if now_hp > @max_hp @sprite_bar_green.src_rect.set(25 - cx, 0, cx, bitmap.height) @wait -= @show_fast ? 2 : 1 end end
QQ图片88820190420202109.png (7.04 KB, 下载次数: 24)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |