Project1
标题: 使用显示敌人血量脚本在战斗结束时会出现脚本错误如何解 [打印本页]
作者: srg123 时间: 2012-11-13 14:24
标题: 使用显示敌人血量脚本在战斗结束时会出现脚本错误如何解
RT附上图
def dispose
if self.bitmap != nil
self.bitmap.dispose
@enemy_hpmp_window.dispose
end
super
end
请问哪里出错了? dsu_plus_rewardpost_czw
作者: srg123 时间: 2012-11-13 20:52
当然有
这脚本本来有显示确切的血量数值 和MP数字我把它改掉了
下面是脚本
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 描绘敌人HP
#--------------------------------------------------------------------------
def draw_enemy_hp(enemy, x, y, width = 80)
draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 0, line_height, Vocab::hp_a)
self.contents.font.color = hp_color(enemy)
self.contents.draw_text(x + width - 0, y, 0, line_height, enemy.hp, 0)
#一个数字占16像素
end
#--------------------------------------------------------------------------
# ● 绘制敌人MP
#--------------------------------------------------------------------------
def draw_enemy_mp(enemy, x, y, width = 0)
draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 0, line_height, Vocab::mp_a)
self.contents.font.color = mp_color(enemy)
self.contents.draw_text(x + width - 0, y,0, line_height, enemy.mp, 0)
end
end
作者: 无名小兵 时间: 2012-11-14 09:29
SBS系统 好像跟这个系统冲突 打完或者逃跑 都提示 没有释放什么精灵。。。然后就PASS这个显血
作者: 芙蕾娅 时间: 2012-11-14 12:19
http://rpg.blue/thread-252003-1-1.html
试试使用编号F08看看?
作者: fuwang 时间: 2012-11-14 21:03
……改成这样试试看?
def dispose
if self.bitmap != nil
self.bitmap.dispose
if @enemy_hpmp_window != nil
@enemy_hpmp_window.dispose
end
end
super
end
作者: 无名小兵 时间: 2012-11-15 18:23
芙蕾娅 发表于 2012-11-14 12:19 
http://rpg.blue/thread-252003-1-1.html
试试使用编号F08看看?
亲,你的显血版本跟SideView没效果哦
作者: 芙蕾娅 时间: 2012-11-15 19:43
本帖最后由 芙蕾娅 于 2012-11-25 13:14 编辑
无名小兵 发表于 2012-11-15 18:23 
亲,你的显血版本跟SideView没效果哦
坐标稍微计算错误,改了些,这下应该有效果了- #==============================================================================
- # F08 - 战斗敌人显示血条·改 - By芙蕾娅
- # 对应横板战斗版本
- #------------------------------------------------------------------------------
- # ★ - 新增 ☆ - 修改 ■ - 删除 ● - 无变更
- #==============================================================================
- module Freya
- # 隐藏HP的文本
- HideGaugeText = "Hide_Gauge"
- # 血条颜色
- EnemyHPGaugeColor1 = Color.new(64,128,96)
- EnemyHPGaugeColor2 = Color.new(96,192,160)
- end
- #==============================================================================
- # ■ Sprite_Battler_HP
- #------------------------------------------------------------------------------
- # 显示战斗者的生命在战斗者的精灵下面。
- #==============================================================================
- class Sprite_Battler_HP < Sprite
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(viewport,battler)
- super(viewport)
- [url=home.php?mod=space&uid=133701]@battler[/url] = battler
- @last_hp = 0
- create_bitmap
- update
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 生成位图
- #--------------------------------------------------------------------------
- def create_bitmap
- @last_hp = @battler.hp
- bw = 96
- bh = 6
- self.bitmap = Bitmap.new(bw, bh)
- self.bitmap.fill_rect(0, 0, bw, bh, Color.new(32,32,64))
- if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
- hp = ((bw) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(0, 0, hp, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- elsif Freya::Gauge_Type == 1
- hp = ((width - 2) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(1, 1, hp, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- elsif Freya::Gauge_Type == 2
- hp = ((width) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(0, 0, hp / 2, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, bh, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
- elsif Freya::Gauge_Type == 3
- hp = ((width - 2) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- unless self.bitmap.nil?
- self.z = @battler.sv.z + 20
- create_bitmap if @last_hp != @battler.hp
- hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
- self.opacity = 0 if @battler.hp == 0 or hide
- end
- end
- end
- #==============================================================================
- # ■ Sprite_Battler
- #------------------------------------------------------------------------------
- # 显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- #--------------------------------------------------------------------------
- # ☆ 初始化对象
- #--------------------------------------------------------------------------
- alias initialize_freya_enemy_hp initialize
- def initialize(viewport, battler = nil)
- initialize_freya_enemy_hp(viewport, battler)
- if @battler.is_a?(Game_Enemy)
- @hp_gauge = Sprite_Battler_HP.new(viewport, battler)
- end
- end
- #--------------------------------------------------------------------------
- # ☆ 释放
- #--------------------------------------------------------------------------
- alias dispose_freya_enemy_hp dispose
- def dispose
- dispose_freya_enemy_hp
- unless @hp_gauge.nil?
- @hp_gauge.dispose
- end
- end
- #--------------------------------------------------------------------------
- # ☆ 更新画面
- #--------------------------------------------------------------------------
- alias update_freya_enemy_hp update
- def update
- update_freya_enemy_hp
- @hp_gauge.update unless @hp_gauge.nil?
- end
- alias update_freya_position update_position
- def update_position
- update_freya_position
- @hp_gauge.x = self.x - 48 unless @hp_gauge.nil?
- @hp_gauge.y = self.y unless @hp_gauge.nil?
- end
- end
复制代码
若要显示名字则把这段覆盖掉原本的def create_bitmap(40~61行)- def create_bitmap
- @last_hp = @battler.hp
- bw = 96
- bh = 24
- self.bitmap = Bitmap.new(bw, bh)
- self.bitmap.fill_rect(0, 0, bw, 6, Color.new(32,32,64))
- if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
- hp = ((bw) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(0, 0, hp, 6, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- elsif Freya::Gauge_Type == 1
- hp = ((width - 2) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(1, 1, hp, 6 - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- elsif Freya::Gauge_Type == 2
- hp = ((width) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(0, 0, hp / 2, 6, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, 6, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
- elsif Freya::Gauge_Type == 3
- hp = ((width - 2) * @battler.hp_rate).to_i
- self.bitmap.gradient_fill_rect(1, 1, hp / 2, 6 - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
- self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, 6 - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
- end
- self.bitmap.draw_text(0,0,bw,24,@battler.name)
- end
复制代码