Class: Kawaii::Scene

Inherits:
Object
  • Object
show all
Defined in:
lib/kawaii/scene.rb

Direct Known Subclasses

Intro

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/kawaii/scene.rb', line 3

def name
  @name
end

#scene_managerObject

Returns the value of attribute scene_manager.



3
4
5
# File 'lib/kawaii/scene.rb', line 3

def scene_manager
  @scene_manager
end

#transition_durationObject

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_drawObject



60
61
# File 'lib/kawaii/scene.rb', line 60

def after_draw
end

#after_updateObject



54
55
# File 'lib/kawaii/scene.rb', line 54

def after_update
end

#before_drawObject



56
57
# File 'lib/kawaii/scene.rb', line 56

def before_draw
end

#before_updateObject



52
53
# File 'lib/kawaii/scene.rb', line 52

def before_update
end

#drawObject



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_hudObject



58
59
# File 'lib/kawaii/scene.rb', line 58

def draw_hud
end

#gameObject



35
36
37
# File 'lib/kawaii/scene.rb', line 35

def game
	@scene_manager.game
end

#loadObject



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