Class: SpriteKit::SceneManager
- Inherits:
-
Object
- Object
- SpriteKit::SceneManager
- Defined in:
- mygame/lib/sprite_kit/scene_manager.rb
Instance Attribute Summary collapse
-
#current_scene ⇒ Object
readonly
Returns the value of attribute current_scene.
-
#next_scene ⇒ Object
writeonly
Sets the attribute next_scene.
-
#scenes ⇒ Object
Returns the value of attribute scenes.
-
#ticking_scene ⇒ Object
readonly
Returns the value of attribute ticking_scene.
Instance Method Summary collapse
-
#initialize(scenes:, current_scene:) ⇒ SceneManager
constructor
A new instance of SceneManager.
- #tick(args) ⇒ Object
Constructor Details
#initialize(scenes:, current_scene:) ⇒ SceneManager
Returns a new instance of SceneManager.
7 8 9 10 11 12 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 7 def initialize(scenes:, current_scene:) @scenes = scenes @next_scene = nil @current_scene = current_scene @ticking_scene = @scenes[@current_scene].new(self) end |
Instance Attribute Details
#current_scene ⇒ Object (readonly)
Returns the value of attribute current_scene.
4 5 6 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 4 def current_scene @current_scene end |
#next_scene=(value) ⇒ Object (writeonly)
Sets the attribute next_scene
3 4 5 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 3 def next_scene=(value) @next_scene = value end |
#scenes ⇒ Object
Returns the value of attribute scenes.
5 6 7 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 5 def scenes @scenes end |
#ticking_scene ⇒ Object (readonly)
Returns the value of attribute ticking_scene.
4 5 6 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 4 def ticking_scene @ticking_scene end |
Instance Method Details
#tick(args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'mygame/lib/sprite_kit/scene_manager.rb', line 14 def tick(args) scene_before_tick = @current_scene @ticking_scene.tick(args) if scene_before_tick != @current_scene raise "Scene was changed incorrectly. Set @next_scene or scene.next_scene to change scenes." end if @next_scene && @next_scene != @current_scene @current_scene = @next_scene @ticking_scene = @scenes[@next_scene].new(self) @next_scene = nil end end |