# 文件名第一位'%'支持4张循环
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● 设定角色的位图
#--------------------------------------------------------------------------
def set_character_bitmap
self.bitmap = Cache.character(@character_name)
sign = @character_name[/^[\!\$]./]
if @character_name[0] == '%'
@cw = bitmap.width / 4
@ch = bitmap.height / 4
elsif sign && sign.include?('$')
@cw = bitmap.width / 3
@ch = bitmap.height / 4
else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
end
self.ox = @cw / 2
self.oy = @ch
end
#--------------------------------------------------------------------------
# ● 源矩形的更新
#--------------------------------------------------------------------------
def update_src_rect
if @tile_id == 0
if @character_name[0] == '%'
sx = ((@character.pattern+1) % 4) * @cw
sy = (@character.direction - 2) / 2 * @ch
else
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
end
end