- 注册时间
- 2005-8-1
- 最后登录
- 2005-9-22
⑥精研
- 积分
- 1665
|
为什么直接用下面的代码,@frame_height = tempbitmap.height/picturephase.to_i,会出现error 不能除以0,,谁知道为什么?
class Sprite_Battler < Animated_Sprite
attr_accessor :battler
attr_reader :index
attr_accessor :target_index
attr_accessor :frame_width
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@pattern_b = 0 #
@counter_b = 0 #
@index = 0 #
if @battler != nil
tempbitmap = RPG::Cache.battler(@battler.battler_name, @battler.battler_hue)
@frame_width = tempbitmap.width/4
picturephase = @battler.picturephase
if picturephase == "66RPG"
@frame_height = tempbitmap.height/8
else
@frame_height = tempbitmap.height/picturephase.to_i
end
else
@frame_width, @frame_height = 1,1
end
# start sprite
@battler.is_a?(Game_Enemy) ? enemy_pose(1) : pose(1)
@battler_visible = false
if $target_index == nil
$target_index = 0
end
end
def index=(index) #
@index = index #
update #
end #
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
def enemy #
$target_index += $game_troop.enemies.size
$target_index %= $game_troop.enemies.size
return $game_troop.enemies[$target_index] #
end #
def actor #
$target_index += $game_party.actors.size
$target_index %= $game_party.actors.size
return $game_party.actors[$target_index] #
end
|
|