Class: OR2D::Scene
- Inherits:
-
Object
- Object
- OR2D::Scene
- Defined in:
- lib/or2d/scene.rb
Overview
A Scene object represents a single scene in an OR2D instance. Each Scene maintains two internal lists to keep track of the visibility state of Entities in the scene. It provides 3 functions to control how the Scene is updated, rendered, and whether or not it should be redrawn. It is recommended to use inheritance to create new scenes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
The ID of the scene.
Instance Method Summary collapse
-
#finish ⇒ Object
Finishes the scene.
-
#finished? ⇒ Boolean
Has the scene finished?.
-
#initialize(id, procs = {}) ⇒ Scene
constructor
Constructs a new Scene object.
-
#redraw? ⇒ Boolean
Should the scene be redrawn?.
-
#render ⇒ Object
Render the scene.
-
#rendered? ⇒ Boolean
Has the scene been rendered?.
-
#update ⇒ Object
Updates the scene.
Constructor Details
#initialize(id, procs = {}) ⇒ Scene
Constructs a new Scene object.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/or2d/scene.rb', line 43 def initialize(id, procs = {}) @id = id @descriptors = {} @workers = {} @visible = Set.new @hidden = Set.new @rendered = false @finish = false procs[:redraw?].nil? ? setup_redraw : setup_redraw(&procs[:redraw?]) procs[:update].nil? ? setup_update : setup_update(&procs[:update]) procs[:render].nil? ? setup_render : setup_render(&procs[:render]) self end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns the ID of the scene.
38 39 40 |
# File 'lib/or2d/scene.rb', line 38 def id @id end |
Instance Method Details
#finish ⇒ Object
Finishes the scene.
76 77 78 79 |
# File 'lib/or2d/scene.rb', line 76 def finish @descriptors.each_value { |descriptor| OR2D.game.window.off(descriptor) } @finish = true end |
#finished? ⇒ Boolean
Has the scene finished?
83 84 85 |
# File 'lib/or2d/scene.rb', line 83 def finished? @finish end |
#redraw? ⇒ Boolean
Should the scene be redrawn?
71 72 73 |
# File 'lib/or2d/scene.rb', line 71 def redraw? @workers[:redraw?].resume end |
#render ⇒ Object
Render the scene.
65 66 67 |
# File 'lib/or2d/scene.rb', line 65 def render @workers[:render].resume end |
#rendered? ⇒ Boolean
Has the scene been rendered?
88 89 90 |
# File 'lib/or2d/scene.rb', line 88 def rendered? @rendered end |
#update ⇒ Object
Updates the scene.
60 61 62 |
# File 'lib/or2d/scene.rb', line 60 def update @workers[:update].resume(self) end |