Auteur: Yukihiro matsumoto
#============================================
# ¡ Sprite_Character
#----------------------------------------------
# @ƒLƒƒƒ‰ƒNƒ^[•Ž¦—p‚̃Xƒvƒ‰ƒCƒg‚Å‚·BGame_Character ƒNƒ‰ƒX‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ð
# ŠÄŽ‹‚µAƒXƒvƒ‰ƒCƒg‚Ìó‘Ô‚ðŽ©“®“I‚ɕω»‚³‚¹‚Ü‚·B
#============================================
class Sprite_Character < RPG::Sprite
#------------------------------------------
# œ ŒöŠJƒCƒ“ƒXƒ^ƒ“ƒX•Ï”
#------------------------------------------
attr_accessor :character # ƒLƒƒƒ‰ƒNƒ^[
#------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»
# viewport : ƒrƒ…[ƒ|[ƒg
# character : ƒLƒƒƒ‰ƒNƒ^[ (Game_Character)
#------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
update
end
#------------------------------------------
# œ ƒtƒŒ[ƒ€XV
#------------------------------------------
def update
super
# ƒ^ƒCƒ‹ IDAƒtƒ@ƒCƒ‹–¼AF‘Š‚Ì‚Ç‚ê‚©‚ªŒ»Ý‚Ì‚à‚̂ƈقȂéê‡
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# ƒ^ƒCƒ‹ ID ‚ƃtƒ@ƒCƒ‹–¼AF‘Š‚ð‹L‰¯
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# ƒ^ƒCƒ‹ ID ‚ª—LŒø‚È’l‚Ìê‡
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# ƒ^ƒCƒ‹ ID ‚ª–³Œø‚È’l‚Ìê‡
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# ‰ÂŽ‹ó‘Ô‚ðÝ’è
self.visible = (not @character.transparent)
# ƒOƒ‰ƒtƒBƒbƒN‚ªƒLƒƒƒ‰ƒNƒ^[‚Ìê‡
if @tile_id == 0
# “]‘—Œ³‚Ì‹éŒ`‚ðÝ’è
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# ƒXƒvƒ‰ƒCƒg‚ÌÀ•W‚ðÝ’è
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# •s“§–¾“xA‡¬•û–@A–΂Ý[‚³‚ðÝ’è
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# ƒAƒjƒ[ƒVƒ‡ƒ“
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end |
|