RPG Maker
 

 Username:
 Password:
   Not a member? Register!

Home > RGSS Script Reference > Sprite_Picture

Sprite_Picture


Inherits from: Sprite

Description: This class performs graphical changes on pictures.

Code


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

Properties


Picture: The Game_Picture object this sprite represents.

Picture_Name: The filename of the picture.

Methods


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. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the Terms of Use.
©2004 - 2008 RPG RPG Revolution, All Rights Reserved. Contact Us · Privacy Policy · Legal Disclaimer
eXTReMe Tracker