赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 12661 |
最后登录 | 2012-2-7 |
在线时间 | 2 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 2 小时
- 注册时间
- 2005-10-25
- 帖子
- 108
|
写了个简易抽象版的.
- #==============================================================================
- # BY 1012 脚本屋·不上网的猫
- #==============================================================================
- # ■ Sprite_Battler
- #------------------------------------------------------------------------------
- # 战斗显示用活动块。Game_Battler 类的实例监视、
- # 活动块的状态的监视、活动块状态自动变化。
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- BAR_WIDTH = 88 # 血槽宽
- BAR_HEIGHT = 6 # 血槽高
- COLOR1 = Color.new(255, 0, 0) # 血槽左颜色
- COLOR2 = Color.new(0, 255, 0) # 血槽右颜色
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # viewport : 视区
- # battler : 战斗者 (Game_Battler)
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- super(viewport)
- @battler = battler
- @battler_visible = false
- @effect_type = 0 # 效果种类
- @effect_duration = 0 # 效果剩余时间
- @bar = Sprite.new(viewport)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- @bar.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @battler == 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
- create_bar
- update_bar
- end
- setup_new_effect
- update_effect
- end
- end
- #--------------------------------------------------------------------------
- # ● 创建血条
- #--------------------------------------------------------------------------
- def create_bar
- @bar.ox = BAR_WIDTH / 2
- @bar.oy = BAR_HEIGHT
- @bar.x = self.x
- @bar.y = @battler.screen_y - @height
- @bar.z = self.z
- @bar.bitmap = Bitmap.new(BAR_WIDTH, BAR_HEIGHT)
- end
- #--------------------------------------------------------------------------
- # ● 更新血槽
- #--------------------------------------------------------------------------
- def update_bar
- width = @battler.hp * 100 * BAR_WIDTH / @battler.maxhp / 100
- @bar.bitmap.gradient_fill_rect(0,0,BAR_WIDTH,BAR_HEIGHT,COLOR1,COLOR2)
- @bar.bitmap.fill_rect(width,0,BAR_WIDTH - width, BAR_HEIGHT,Color.new(0,0,0))
- end
- #--------------------------------------------------------------------------
- # ● 更新死亡效果
- #--------------------------------------------------------------------------
- def update_collapse
- self.blend_type = 1
- self.color.set(255, 128, 128, 128)
- self.opacity = 256 - (48 - @effect_duration) * 6
- @bar.blend_type = 1
- @bar.color.set(255, 128, 128, 128)
- @bar.opacity = 256 - (48 - @effect_duration) * 6
- end
- end
复制代码 |
|