Class: SDL2::Engine::Engines
- Inherits:
-
SDL2::Engine
- Object
- SDL2::Engine
- SDL2::Engine::Engines
- Defined in:
- lib/sdl2/engine/engines.rb
Overview
An engine multiplexor. Only has one focus, but that focus can change.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#engines ⇒ Object
readonly
Returns the value of attribute engines.
Attributes inherited from SDL2::Engine
Instance Method Summary collapse
- #current_engine ⇒ Object
- #handle_event(event) ⇒ Object
-
#initialize(opts) ⇒ Engines
constructor
A new instance of Engines.
- #paint_to(surface) ⇒ Object
- #quit ⇒ Object
Methods inherited from SDL2::Engine
Constructor Details
#initialize(opts) ⇒ Engines
Returns a new instance of Engines.
9 10 11 12 13 |
# File 'lib/sdl2/engine/engines.rb', line 9 def initialize(opts) super(opts) @engines = [] #opts[:engines] || [] @current_idx = 0 end |
Instance Attribute Details
#engines ⇒ Object (readonly)
Returns the value of attribute engines.
15 16 17 |
# File 'lib/sdl2/engine/engines.rb', line 15 def engines @engines end |
Instance Method Details
#current_engine ⇒ Object
17 18 19 |
# File 'lib/sdl2/engine/engines.rb', line 17 def current_engine @engines[@current_idx] end |
#handle_event(event) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/sdl2/engine/engines.rb', line 21 def handle_event(event) return true if super(event) # self swallowed event. if current_engine puts "Passing to current engine."if SDL2::PrintDebug return true if current_engine.handle_event(event) end puts "Unable to handle"if SDL2::PrintDebug return false # if we get to here. end |
#paint_to(surface) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/sdl2/engine/engines.rb', line 31 def paint_to(surface) if ce = current_engine return ce.paint_to(surface) else return false end end |
#quit ⇒ Object
39 40 41 42 |
# File 'lib/sdl2/engine/engines.rb', line 39 def quit() @engines.each(&:quit) super() end |