Class: FelFlame::Stage
- Inherits:
-
Object
- Object
- FelFlame::Stage
- Defined in:
- lib/felflame.rb,
lib/felflame/stage_manager.rb
Overview
Stores Scenes which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order.
Class Attribute Summary collapse
-
.scenes ⇒ Array<Scene>
readonly
Contains all the Scenes added to the Stage.
Class Method Summary collapse
-
.add(*scenes_to_add) ⇒ Boolean
Add any number of Scenes to the Stage.
-
.call ⇒ Boolean
Executes one frame of the game.
-
.clear ⇒ Boolean
Clears all Scenes that were added to the Stage.
-
.remove(*scenes_to_remove) ⇒ Boolean
Remove any number of Scenes from the Stage.
Class Attribute Details
.scenes ⇒ Array<Scene>
Contains all the Scenes added to the Stage
58 59 60 |
# File 'lib/felflame/stage_manager.rb', line 58 def scenes @scenes ||= [] end |
Class Method Details
.add(*scenes_to_add) ⇒ Boolean
Add any number of Scenes to the Stage
11 12 13 14 15 16 17 18 |
# File 'lib/felflame/stage_manager.rb', line 11 def add(*scenes_to_add) self.scenes |= scenes_to_add scenes_to_add.each do |scene| self.systems |= scene.systems end systems.sort_by!(&:priority) true end |
.call ⇒ Boolean
Executes one frame of the game. This executes all the Systems in the Scenes added to the Stage. Systems that exist in two or more different Scenes will still only get executed once.
51 52 53 54 |
# File 'lib/felflame/stage_manager.rb', line 51 def call systems.each(&:call) true end |
.clear ⇒ Boolean
Clears all Scenes that were added to the Stage
43 44 45 46 47 |
# File 'lib/felflame/stage_manager.rb', line 43 def clear systems.clear scenes.clear true end |
.remove(*scenes_to_remove) ⇒ Boolean
Remove any number of Scenes from the Stage
22 23 24 25 26 |
# File 'lib/felflame/stage_manager.rb', line 22 def remove(*scenes_to_remove) self.scenes -= scenes_to_remove update_systems_list true end |