Class: BadSdl::Engine::Engines
Overview
An engine multiplexor. Only has one focus, but that focus can change.
Instance Attribute Summary collapse
#surface
Instance Method Summary
collapse
#on, #on_handlers, #painter
Constructor Details
#initialize(opts) ⇒ Engines
Returns a new instance of Engines.
10
11
12
13
14
|
# File 'lib/bad_sdl/engine/engines.rb', line 10
def initialize(opts)
super(opts)
@engines = [] @current_idx = 0
end
|
Instance Attribute Details
#engines ⇒ Object
Returns the value of attribute engines.
16
17
18
|
# File 'lib/bad_sdl/engine/engines.rb', line 16
def engines
@engines
end
|
Instance Method Details
#current_engine ⇒ Object
18
19
20
|
# File 'lib/bad_sdl/engine/engines.rb', line 18
def current_engine
@engines[@current_idx]
end
|
#handle_event(event) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/bad_sdl/engine/engines.rb', line 22
def handle_event(event)
return true if super(event) if current_engine
Debug.log(self){"Passing to current engine."}
return true if current_engine.handle_event(event)
end
SDL2::Debug.log(self){"Unable to handle"}
return false end
|
#paint_to(surface) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/bad_sdl/engine/engines.rb', line 32
def paint_to(surface)
result = false
result = true if super(surface)
if ce = current_engine
result = true if ce.paint_to(surface)
end
return result
end
|
#quit ⇒ Object
43
44
45
46
|
# File 'lib/bad_sdl/engine/engines.rb', line 43
def quit()
@engines.each(&:quit)
super()
end
|