Class: FelFlame::Scenes
- Inherits:
-
Object
- Object
- FelFlame::Scenes
- Defined in:
- lib/felflame.rb,
lib/felflame/scene_manager.rb
Overview
Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the Scenes namespace as Constants.
TODO: Improve Scenes overview
Instance Attribute Summary collapse
-
#const_name ⇒ Object
readonly
The Constant name assigned to this Scene.
-
#systems ⇒ Array<System>
readonly
The list of Systems this Scene contains.
Instance Method Summary collapse
-
#add(*systems_to_add) ⇒ Boolean
Adds any number of Systems to this Scene.
-
#call ⇒ Boolean
Execute all systems in this Scene, in the order of their priority.
-
#clear ⇒ Boolean
Removes all Systems from this Scene.
-
#initialize(name) ⇒ Scenes
constructor
Create a new Scene using the name given.
-
#remove(*systems_to_remove) ⇒ Boolean
Removes any number of Systems from this Scene.
Constructor Details
Instance Attribute Details
#const_name ⇒ Object (readonly)
The Constant name assigned to this Scene
4 5 6 |
# File 'lib/felflame/scene_manager.rb', line 4 def const_name @const_name end |
#systems ⇒ Array<System>
The list of Systems this Scene contains
21 22 23 |
# File 'lib/felflame/scene_manager.rb', line 21 def systems @systems ||= [] end |
Instance Method Details
#add(*systems_to_add) ⇒ Boolean
Adds any number of Systems to this Scene
34 35 36 37 38 39 |
# File 'lib/felflame/scene_manager.rb', line 34 def add(*systems_to_add) self.systems |= systems_to_add self.systems = systems.sort_by(&:priority) FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end |
#call ⇒ Boolean
Execute all systems in this Scene, in the order of their priority
27 28 29 30 |
# File 'lib/felflame/scene_manager.rb', line 27 def call systems.each(&:call) true end |
#clear ⇒ Boolean
Removes all Systems from this Scene
52 53 54 55 56 |
# File 'lib/felflame/scene_manager.rb', line 52 def clear systems.clear FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end |
#remove(*systems_to_remove) ⇒ Boolean
Removes any number of Systems from this Scene
43 44 45 46 47 48 |
# File 'lib/felflame/scene_manager.rb', line 43 def remove(*systems_to_remove) self.systems -= systems_to_remove self.systems = systems.sort_by(&:priority) FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end |