Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Sprite_MenuBack
- #------------------------------------------------------------------------------
- # This sprite is used to display sprites behind menus
- #==============================================================================
- class Sprite_MenuBack < Sprite_Base
- attr_reader :ID # reference ID
- #--------------------------------------------------------------------------
- # * Object Initialization
- # picture : Game_Picture
- #--------------------------------------------------------------------------
- def initialize(x,y,name,alpha,myID="not given")
- @name = name
- @x=x
- @y=y
- @targx=x
- @targy=y
- @alpha=alpha
- @targa=alpha
- @duration=0
- @shake_duration=-1
- @shake_x_severity=0
- @shake_y_severity=0
- @shake_ox=x
- @shake_oy=y
- @ID = myID
- @origin =0
- @tone = Tone.new
- @hue = 0
- update
- end
- #--------------------------------------------------------------------------
- # * Free
- #--------------------------------------------------------------------------
- def dispose
- printf "disposed of?\n"
- bitmap.dispose if bitmap
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- update_bitmap
- update_origin
- update_position
- update_shake
- end
- #--------------------------------------------------------------------------
- # * Update Transfer Origin Bitmap
- #--------------------------------------------------------------------------
- def update_bitmap
- if @name==""
- @bitmap = nil
- else
- @bitmap = Cache.battler(@name,@hue)
- end
- @rect=Rect.new(0,0,@bitmap.width,@bitmap.height)
- end
- #--------------------------------------------------------------------------
- # * Update Origin
- #--------------------------------------------------------------------------
- def update_origin
- #if @origin == 0
- # self.ox = 0
- # self.oy = 0
- #else
- # self.ox = @cropped.width / 2
- # self.oy = @cropped.height / 2
- #end
- end
- #--------------------------------------------------------------------------
- # * Update Position
- #--------------------------------------------------------------------------
- def update_position
- return if @duration == 0
- d = @duration
- @x = (@x * (d - 1) + @targx) / d.to_f
- @y = (@y * (d - 1) + @targy) / d.to_f
- @alpha = (@alpha * (d - 1) + @targa) / d.to_f
- @duration -= 1
- end
- def update_shake
- if @shake_duration == 0
- @x=@shake_ox
- @y=@shake_oy
- @shake_duration -= 1
- return
- end
- return if @shake_duration == -1
- d = @shake_duration
- @x = @shake_ox+(-@shake_x_severity + (1+rand(@shake_x_severity*2)))
- @y = @shake_oy+(-@shake_y_severity + (1+rand(@shake_y_severity*2)))
- @shake_duration -= 1
- end
- def set_shake(x,y,d)
- @shake_ox=@x
- @shake_oy=@y
- @shake_x_severity=x
- @shake_y_severity=y
- @shake_duration=d
- end
- def set_target(x,y,a,d)
- if d==0
- @x=x
- @y=y
- @alpha=a
- else
- @targx=x
- @targy=y
- @targa=a
- end
- @duration=d
- #printf "setting target of %s\n",@ID
- end
- def blt_to_target(target)
- target.blt(@x,@y,@bitmap,@rect,@alpha)
- end
- end
RAW Paste Data