Class: Yuki::Parallax_Object
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb
Overview
Object that describe a parallax as a particle
Instance Attribute Summary collapse
-
#disposed ⇒ Boolean
(also: #disposed?)
readonly
If the parallax is disposed.
-
#factor_x ⇒ Numeric
the factor that creates an automatic offset in x.
-
#factor_y ⇒ Numeric
the factor that creates an automatic offset in y.
-
#sprite ⇒ Sprite
The parallax sprite.
Instance Method Summary collapse
-
#dispose
Dispose the parallax.
-
#initialize(image, x, y, z, zoom_x = 1, zoom_y = 1, opacity = 255, blend_type = 0) ⇒ Parallax_Object
constructor
Creates a new Parallax_Object.
-
#update
Update the parallax position.
Constructor Details
#initialize(image, x, y, z, zoom_x = 1, zoom_y = 1, opacity = 255, blend_type = 0) ⇒ Parallax_Object
Creates a new Parallax_Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 26 def initialize(image, x, y, z, zoom_x = 1, zoom_y = 1, opacity = 255, blend_type = 0) @sprite = ::Sprite.new(Particles., true) @sprite.z = z @sprite.zoom_x = zoom_x @sprite.zoom_y = zoom_y @sprite.opacity = opacity @sprite.blend_type = blend_type @sprite.bitmap = ::RPG::Cache.picture(image) @x = x + MapLinker.get_OffsetX * 16 @y = y + MapLinker.get_OffsetY * 16 @factor_x = 0 @factor_y = 0 @map_id = $game_map.map_id update end |
Instance Attribute Details
#disposed ⇒ Boolean (readonly) Also known as: disposed?
If the parallax is disposed
7 8 9 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 7 def disposed @disposed end |
#factor_x ⇒ Numeric
the factor that creates an automatic offset in x
13 14 15 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 13 def factor_x @factor_x end |
#factor_y ⇒ Numeric
the factor that creates an automatic offset in y
16 17 18 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 16 def factor_y @factor_y end |
#sprite ⇒ Sprite
The parallax sprite
10 11 12 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 10 def sprite @sprite end |
Instance Method Details
#dispose
Dispose the parallax
54 55 56 57 58 59 60 61 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 54 def dispose return if disposed? @sprite.dispose unless @sprite.disposed? @sprite = nil @disposed = true Yuki::Particles.clean_stack end |
#update
Update the parallax position
43 44 45 46 47 48 49 50 51 |
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00504 Parallax_Object.rb', line 43 def update return if disposed? return dispose if @map_id != $game_map.map_id dx = $game_map.display_x / 8 dy = $game_map.display_y / 8 @sprite.x = (@x - dx) + (@factor_x * dx) @sprite.y = (@y - dy) + (@factor_y * dy) end |