Class: Kawaii::Scene
- Inherits:
-
Object
- Object
- Kawaii::Scene
- Defined in:
- lib/kawaii/scene.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#scene_manager ⇒ Object
Returns the value of attribute scene_manager.
-
#transition_duration ⇒ Object
Returns the value of attribute transition_duration.
Instance Method Summary collapse
- #add_child(node) ⇒ Object
- #after_draw ⇒ Object
- #after_update ⇒ Object
- #before_draw ⇒ Object
- #before_update ⇒ Object
- #draw ⇒ Object
- #draw_hud ⇒ Object
- #game ⇒ Object
-
#initialize(scene_manager) ⇒ Scene
constructor
A new instance of Scene.
- #load ⇒ Object
- #remove_child(node) ⇒ Object
- #transition_in(current, duration) ⇒ Object
- #transition_out(current, duration) ⇒ Object
- #update(dt) ⇒ Object
Constructor Details
#initialize(scene_manager) ⇒ Scene
Returns a new instance of Scene.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kawaii/scene.rb', line 5 def initialize scene_manager @scene_manager = scene_manager # managers @node_manager = Kawaii::NodeManager.new @content = Kawaii::ContentManager.new(scene_manager.game, scene_manager.game.content_root) @audio = Kawaii::AudioManager.new(scene_manager.game) @input = Kawaii::InputManager.new(scene_manager.game) @physics = Kawaii::PhysicsManager.new # cam @cam = Kawaii::Camera.new(scene_manager.game) # set default duration @transition_duration = SCENE_TRANSITION_DURATION load() end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/kawaii/scene.rb', line 3 def name @name end |
#scene_manager ⇒ Object
Returns the value of attribute scene_manager.
3 4 5 |
# File 'lib/kawaii/scene.rb', line 3 def scene_manager @scene_manager end |
#transition_duration ⇒ Object
Returns the value of attribute transition_duration.
3 4 5 |
# File 'lib/kawaii/scene.rb', line 3 def transition_duration @transition_duration end |
Instance Method Details
#add_child(node) ⇒ Object
24 25 26 |
# File 'lib/kawaii/scene.rb', line 24 def add_child node @node_manager.nodes.push node end |
#after_draw ⇒ Object
60 61 |
# File 'lib/kawaii/scene.rb', line 60 def after_draw end |
#after_update ⇒ Object
54 55 |
# File 'lib/kawaii/scene.rb', line 54 def after_update end |
#before_draw ⇒ Object
56 57 |
# File 'lib/kawaii/scene.rb', line 56 def before_draw end |
#before_update ⇒ Object
52 53 |
# File 'lib/kawaii/scene.rb', line 52 def before_update end |
#draw ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/kawaii/scene.rb', line 63 def draw @cam.translate do before_draw @node_manager.draw after_draw end draw_hud end |
#draw_hud ⇒ Object
58 59 |
# File 'lib/kawaii/scene.rb', line 58 def draw_hud end |
#game ⇒ Object
35 36 37 |
# File 'lib/kawaii/scene.rb', line 35 def game @scene_manager.game end |
#load ⇒ Object
32 33 |
# File 'lib/kawaii/scene.rb', line 32 def load end |
#remove_child(node) ⇒ Object
28 29 30 |
# File 'lib/kawaii/scene.rb', line 28 def remove_child node @node_manager.nodes.delete node end |
#transition_in(current, duration) ⇒ Object
39 40 |
# File 'lib/kawaii/scene.rb', line 39 def transition_in current, duration end |
#transition_out(current, duration) ⇒ Object
42 43 |
# File 'lib/kawaii/scene.rb', line 42 def transition_out current, duration end |
#update(dt) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/kawaii/scene.rb', line 45 def update dt @input.update before_update() @node_manager.update dt after_update() end |