Class: Metro::Window
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Metro::Window
- Defined in:
- lib/metro/window.rb
Overview
A subclass of the Gosu::Window which simply acts as system to shuffle in and out scenes and relay event information.
Instance Attribute Summary collapse
-
#cursor ⇒ Object
(also: #needs_cursor?)
Define an acessor that enables/disables the use of a cursor within the window.
-
#scene ⇒ Object
The scene of the window.
Instance Method Summary collapse
-
#button_down(id) ⇒ Object
Called before #update when the user presses a button while the window has focus.
-
#button_up(id) ⇒ Object
Called before #update when the user releases a button while the window has focus.
-
#dimensions ⇒ Object
The dimensions of the current window.
-
#draw ⇒ Object
This is called after every #update and when the OS wants the window to repaint itself.
- #hide_cursor ⇒ Object
-
#initialize(width, height, fullscreen) ⇒ Window
constructor
A new instance of Window.
- #show_cursor ⇒ Object
- #state ⇒ Object
-
#update ⇒ Object
This is called every update interval while the window is being shown.
Constructor Details
#initialize(width, height, fullscreen) ⇒ Window
Returns a new instance of Window.
26 27 28 |
# File 'lib/metro/window.rb', line 26 def initialize(width,height,fullscreen) super width, height, fullscreen end |
Instance Attribute Details
#cursor ⇒ Object Also known as: needs_cursor?
Define an acessor that enables/disables the use of a cursor within the window. The value should be truthy/falsy.
78 79 80 |
# File 'lib/metro/window.rb', line 78 def cursor @cursor end |
#scene ⇒ Object
The scene of the window.
14 15 16 |
# File 'lib/metro/window.rb', line 14 def scene @scene end |
Instance Method Details
#button_down(id) ⇒ Object
Called before #update when the user presses a button while the window has focus.
63 64 65 |
# File 'lib/metro/window.rb', line 63 def (id) state.(id) end |
#button_up(id) ⇒ Object
Called before #update when the user releases a button while the window has focus.
55 56 57 |
# File 'lib/metro/window.rb', line 55 def (id) state.(id) end |
#dimensions ⇒ Object
Returns the dimensions of the current window.
70 71 72 |
# File 'lib/metro/window.rb', line 70 def dimensions Metro::Units::Dimensions.of width, height end |
#draw ⇒ Object
This is called after every #update and when the OS wants the window to repaint itself.
47 48 49 |
# File 'lib/metro/window.rb', line 47 def draw scene.base_draw end |
#hide_cursor ⇒ Object
89 90 91 |
# File 'lib/metro/window.rb', line 89 def hide_cursor self.cursor = false end |
#show_cursor ⇒ Object
85 86 87 |
# File 'lib/metro/window.rb', line 85 def show_cursor self.cursor = true end |
#state ⇒ Object
16 17 18 |
# File 'lib/metro/window.rb', line 16 def state scene.state end |
#update ⇒ Object
This is called every update interval while the window is being shown.
38 39 40 41 |
# File 'lib/metro/window.rb', line 38 def update state. scene.base_update end |