Class: Slickr::Entity
- Inherits:
-
Object
- Object
- Slickr::Entity
- Defined in:
- lib/slickr/entity.rb
Class Attribute Summary collapse
Class Method Summary collapse
- .reset ⇒ Object
-
.use(behavior, options = {}) ⇒ Object
Specify that an Entity should behave a certain way.
Instance Method Summary collapse
- #behaviors ⇒ Object
-
#initialize ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize ⇒ Entity
Returns a new instance of Entity.
42 43 44 |
# File 'lib/slickr/entity.rb', line 42 def initialize behaviors.each { |behavior, | behave_like(behavior, ) } end |
Class Attribute Details
.behaviors ⇒ Object
34 35 36 |
# File 'lib/slickr/entity.rb', line 34 def self.behaviors @behaviors ||= [] end |
Class Method Details
.reset ⇒ Object
38 39 40 |
# File 'lib/slickr/entity.rb', line 38 def self.reset @behaviors = [] end |
.use(behavior, options = {}) ⇒ Object
Specify that an Entity should behave a certain way.
Different Behaviors will allow you to specify different default values. For example, a Spatiality behavior that allows an Entity to move about the world, may take a default x and y value. The Entity will be placed at that location when the scene is first loaded.
30 31 32 |
# File 'lib/slickr/entity.rb', line 30 def self.use(behavior, ={}) behaviors << [behavior, ] end |
Instance Method Details
#behaviors ⇒ Object
46 47 48 |
# File 'lib/slickr/entity.rb', line 46 def behaviors self.class.behaviors end |