Class: Wads::WadsApp
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Wads::WadsApp
- Defined in:
- lib/wads/app.rb
Overview
The WadsApp class provides a simple starting point to quickly build a native Ruby application using Gosu as an underlying library. It provides all the necessary hooks to get started. All you need to do is supply the parent Wads widget using the set_display(widget) method. See one of the Wads samples for example usage.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #button_up(id) ⇒ Object
- #draw ⇒ Object
- #get_display ⇒ Object
-
#initialize(width, height, caption, widget) ⇒ WadsApp
constructor
A new instance of WadsApp.
-
#set_display(widget) ⇒ Object
This method must be invoked with any Wads::Widget instance.
- #update ⇒ Object
Constructor Details
#initialize(width, height, caption, widget) ⇒ WadsApp
Returns a new instance of WadsApp.
12 13 14 15 16 17 18 19 |
# File 'lib/wads/app.rb', line 12 def initialize(width, height, caption, ) super(width, height) self.caption = caption @update_count = 0 WadsConfig.instance.set_window(self) set_display() WadsConfig.instance.set_log_level("info") end |
Instance Method Details
#button_down(id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wads/app.rb', line 42 def id close if id == Gosu::KbEscape # Delegate button events to the primary display widget result = @main_widget. id, mouse_x, mouse_y if not result.nil? and result.is_a? WidgetResult if result. close end end end |
#button_up(id) ⇒ Object
53 54 55 |
# File 'lib/wads/app.rb', line 53 def id @main_widget. id, mouse_x, mouse_y end |
#draw ⇒ Object
38 39 40 |
# File 'lib/wads/app.rb', line 38 def draw @main_widget.draw end |
#get_display ⇒ Object
29 30 31 |
# File 'lib/wads/app.rb', line 29 def get_display @main_widget end |
#set_display(widget) ⇒ Object
This method must be invoked with any Wads::Widget instance. It then handles delegating all events and drawing all child widgets.
25 26 27 |
# File 'lib/wads/app.rb', line 25 def set_display() @main_widget = end |
#update ⇒ Object
33 34 35 36 |
# File 'lib/wads/app.rb', line 33 def update @main_widget.update(@update_count, mouse_x, mouse_y) @update_count = @update_count + 1 end |