Home > RGSS Script Reference > Sprite_Picture
Sprite_Picture
Inherits from: Sprite
Description: This class performs graphical changes on pictures.
class Sprite_Picture < RPG::Sprite
# ------------------------------------
def initialize(viewport, picture)
super(viewport)
@picture = picture
update
end
# ------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
# ------------------------------------
def update
super
if @picture_name != @picture.name
@picture_name = @picture.name
if @picture_name != ""
self.bitmap = RPG::Cache.picture(@picture_name)
end
end
if @picture_name == ""
self.visible = false
return
end
self.visible = true
if @picture.origin == 0
self.ox = 0
self.oy = 0
else
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
end
self.x = @picture.x
self.y = @picture.y
self.z = @picture.number
self.zoom_x = @picture.zoom_x / 100.0
self.zoom_y = @picture.zoom_y / 100.0
self.opacity = @picture.opacity
self.blend_type = @picture.blend_type
self.angle = @picture.angle
self.tone = @picture.tone
end
end
|
Picture: The Game_Picture object this sprite represents.
Picture_Name: The filename of the picture.
Initialize
Arguments: None
Local Variables: None
How it Works: This method sets the picture to which the sprite belongs and updates the picture so that its disposition is proper.
Dispose
Arguments: None
Local Variables: None
How it Works: This method is the garbage collection method for this sprite. It first sets the sprite's bitmap to nil, then disposes of that bitmap. It then calls Sprite#Dispose in order to do further garbage collection.
Update
Arguments: None
Local Variables: None
How it Works: This method updates the picture's graphics each frame. First, the call to super performs frame update processing common to all sprites. The if @picture_name != @picture.name statement checks to see if the picture's filename has changed. If it has, then the new filename is assigned to @picture_name. If the picture name is "" (erased), then the picture's visible flag is set to false. If the picture's origin is 0 (Relative to Upper-left Pixel), then the picture isn't displaced at all. If the picture's origin is 1 (Center pixel), then it's displaced to the left by half its width and down by half its height. The next three statements set the picture's X, Y, and Z coordinates. The rest of the statements set other picture properties.
|
|