Class: Viewport

Inherits:
Object
  • Object
show all
Defined in:
lib/openrgss/viewport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Viewport

:call-seq: Viewport.new(x, y, width, height) Viewport.new(rect) Viewport.new (RGSS3)

Creates a viewport object.

Same size as the screen if no argument is specified.



39
40
41
42
43
44
45
46
47
# File 'lib/openrgss/viewport.rb', line 39

def initialize(*args)
  @tone       = Tone.new
  @color      = Color.new
  @rect       = args.empty? ? Rect.new(0, 0, Graphics.width, Graphics.height) : Rect.new(*args)
  @created_at = Time.now
  @z          = 0
  @ox         = 0
  @oy         = 0
end

Instance Attribute Details

#colorObject

The color (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.



23
24
25
# File 'lib/openrgss/viewport.rb', line 23

def color
  @color
end

#created_atObject

Returns the value of attribute created_at.



28
29
30
# File 'lib/openrgss/viewport.rb', line 28

def created_at
  @created_at
end

#oxObject

The x-coordinate of the viewport’s starting point. Change this value to shake the screen, etc.



15
16
17
# File 'lib/openrgss/viewport.rb', line 15

def ox
  @ox
end

#oyObject

The y-coordinate of the viewport’s starting point. Change this value to shake the screen, etc.



18
19
20
# File 'lib/openrgss/viewport.rb', line 18

def oy
  @oy
end

#rectObject

The box (Rect) defining the viewport.



3
4
5
# File 'lib/openrgss/viewport.rb', line 3

def rect
  @rect
end

#toneObject

The viewport’s color tone (Tone).



26
27
28
# File 'lib/openrgss/viewport.rb', line 26

def tone
  @tone
end

#visibleObject

The viewport’s visibility. If TRUE, the viewport is visible. The default is TRUE.



6
7
8
# File 'lib/openrgss/viewport.rb', line 6

def visible
  @visible
end

#zObject

The viewport’s z-coordinate. The larger the value, the closer to the player the plane will be displayed.

If multiple objects share the same z-coordinate, the more recently created object will be displayed closest to the player.



12
13
14
# File 'lib/openrgss/viewport.rb', line 12

def z
  @z
end

Instance Method Details

#disposeObject

Frees the viewport. If the viewport has already been freed, does nothing.

This operation will not result in a separate associated object being automatically freed.



53
54
55
# File 'lib/openrgss/viewport.rb', line 53

def dispose
  @disposed = true
end

#disposed?Boolean

Returns TRUE if the viewport has been freed.

Returns:

  • (Boolean)


59
60
61
# File 'lib/openrgss/viewport.rb', line 59

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.



67
68
69
# File 'lib/openrgss/viewport.rb', line 67

def flash(color, duration)

end

#updateObject

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.



74
75
76
# File 'lib/openrgss/viewport.rb', line 74

def update

end