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.
79 80 81 |
# File 'lib/metro/window.rb', line 79 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.
64 65 66 |
# File 'lib/metro/window.rb', line 64 def (id) state.(id) end |
#button_up(id) ⇒ Object
Called before #update when the user releases a button while the window has focus.
56 57 58 |
# File 'lib/metro/window.rb', line 56 def (id) state.(id) end |
#dimensions ⇒ Object
Returns the dimensions of the current window.
71 72 73 |
# File 'lib/metro/window.rb', line 71 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.
48 49 50 |
# File 'lib/metro/window.rb', line 48 def draw scene.base_draw end |
#hide_cursor ⇒ Object
90 91 92 |
# File 'lib/metro/window.rb', line 90 def hide_cursor self.cursor = false end |
#show_cursor ⇒ Object
86 87 88 |
# File 'lib/metro/window.rb', line 86 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 42 |
# File 'lib/metro/window.rb', line 38 def update state.fire_events_for_mouse_movement state. scene.base_update end |