Class: Viewport
- Inherits:
-
Object
- Object
- Viewport
- Defined in:
- lib/viewport.rb
Overview
The viewport class. Used when displaying sprites in one portion of the screen, with no overflow into other regions.
Instance Attribute Summary collapse
-
#color ⇒ Object
The Color to be blended with the viewport.
-
#ox ⇒ Object
The X-coordinate of the viewport’s starting point.
-
#oy ⇒ Object
The Y-coordinate of the viewport’s starting point.
-
#rect ⇒ Object
The Rect defining the viewport.
-
#tone ⇒ Object
The viewport’s color Tone.
-
#visible ⇒ Object
The viewport’s visibility.
-
#z ⇒ Object
The viewport’s Z-coordinate.
Instance Method Summary collapse
-
#dispose ⇒ Object
Frees the viewport.
-
#disposed? ⇒ Boolean
Returns TRUE if the viewport has been freed.
-
#flash(color, duration) ⇒ Object
Begins flashing the viewport.
-
#initialize ⇒ Viewport
constructor
new(x, y, width, height) new(rect).
-
#update ⇒ Object
Refreshes the viewport flash.
Constructor Details
#initialize ⇒ Viewport
new(x, y, width, height) new(rect)
37 38 39 |
# File 'lib/viewport.rb', line 37 def initialize raise "not implemented" end |
Instance Attribute Details
#color ⇒ Object
The Color to be blended with the viewport. Alpha values are used in the blending ratio.
Handled separately from the color blended into a flash effect.
29 30 31 |
# File 'lib/viewport.rb', line 29 def color @color end |
#ox ⇒ Object
The X-coordinate of the viewport’s starting point. Change this value to shake the screen, etc.
19 20 21 |
# File 'lib/viewport.rb', line 19 def ox @ox end |
#oy ⇒ Object
The Y-coordinate of the viewport’s starting point. Change this value to shake the screen, etc.
23 24 25 |
# File 'lib/viewport.rb', line 23 def oy @oy end |
#rect ⇒ Object
The Rect defining the viewport.
6 7 8 |
# File 'lib/viewport.rb', line 6 def rect @rect end |
#tone ⇒ Object
The viewport’s color Tone.
33 34 35 |
# File 'lib/viewport.rb', line 33 def tone @tone end |
#visible ⇒ Object
The viewport’s visibility. If TRUE, the viewport is visible.
9 10 11 |
# File 'lib/viewport.rb', line 9 def visible @visible end |
#z ⇒ Object
The viewport’s Z-coordinate. The larger this value, the closer to the player the viewport will be displayed. If multiple objects share the same Z-coordinate, the more recently created object will be displayed closest to the player.
15 16 17 |
# File 'lib/viewport.rb', line 15 def z @z end |
Instance Method Details
#dispose ⇒ Object
Frees the viewport. If the viewport has already been freed, does nothing.
42 43 44 |
# File 'lib/viewport.rb', line 42 def dispose @disposed = true end |
#disposed? ⇒ Boolean
Returns TRUE if the viewport has been freed.
47 48 49 |
# File 'lib/viewport.rb', line 47 def disposed? @disposed end |
#flash(color, duration) ⇒ Object
Begins flashing the viewport. duration specifies the number of frames the flash will last.
If color is set to nil, the viewport will disappear while flashing.
54 55 56 |
# File 'lib/viewport.rb', line 54 def flash(color, duration) raise "not implemented" end |
#update ⇒ Object
Refreshes the viewport flash. As a rule, this method is called once per frame.
It is not necessary to call this method if no flash effect is needed.
61 62 63 |
# File 'lib/viewport.rb', line 61 def update raise "not implemented" end |