# -*- coding: utf-8 -*- #============================================================================== # ** Sprite_Picture #------------------------------------------------------------------------------ # This sprite is used to display pictures. It observes an instance of the # Game_Picture class and automatically changes sprite states. #============================================================================== class Sprite_Picture < Sprite #-------------------------------------------------------------------------- # * Object Initialization # picture : Game_Picture #-------------------------------------------------------------------------- def initialize(viewport, picture) super(viewport) @picture = picture update end #-------------------------------------------------------------------------- # * Free #-------------------------------------------------------------------------- def dispose bitmap.dispose if bitmap super end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super update_bitmap update_origin update_position update_zoom update_other end #-------------------------------------------------------------------------- # * Update Transfer Origin Bitmap #-------------------------------------------------------------------------- def update_bitmap if @picture.name.empty? self.bitmap = nil else self.bitmap = Cache.picture(@picture.name) end end #-------------------------------------------------------------------------- # * Update Origin #-------------------------------------------------------------------------- def update_origin if @picture.origin == 0 self.ox = 0 self.oy = 0 else self.ox = bitmap.width / 2 self.oy = bitmap.height / 2 end end #-------------------------------------------------------------------------- # * Update Position #-------------------------------------------------------------------------- def update_position self.x = @picture.x self.y = @picture.y self.z = @picture.number end #-------------------------------------------------------------------------- # * Update Zoom Factor #-------------------------------------------------------------------------- def update_zoom self.zoom_x = @picture.zoom_x / 100.0 self.zoom_y = @picture.zoom_y / 100.0 end #-------------------------------------------------------------------------- # * Update Other #-------------------------------------------------------------------------- def update_other self.opacity = @picture.opacity self.blend_type = @picture.blend_type self.angle = @picture.angle self.tone.set(@picture.tone) end end