Class: Kawaii::PhysicsEntity
- Defined in:
- lib/kawaii/physics_entity.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#geom ⇒ Object
Returns the value of attribute geom.
-
#shape ⇒ Object
Returns the value of attribute shape.
Attributes inherited from Entity
#flipped_h, #flipped_v, #texture
Attributes inherited from Node
#children, #gravity, #position, #rotation, #static, #velocity
Instance Method Summary collapse
- #add_to_space(chipmunk_space) ⇒ Object
-
#initialize(geom, args) ⇒ PhysicsEntity
constructor
A new instance of PhysicsEntity.
- #remove_from_space(chipmunk_space) ⇒ Object
Methods inherited from Entity
#after_update, #before_update, #draw
Methods inherited from Node
#add_child, #count, #draw, #has_children?, #remove_child, #update
Constructor Details
#initialize(geom, args) ⇒ PhysicsEntity
Returns a new instance of PhysicsEntity.
8 9 10 11 12 13 14 15 16 |
# File 'lib/kawaii/physics_entity.rb', line 8 def initialize geom, args @geom = geom case geom when :circle create_circle(args[:radius]) when :rectangle create_rectangle(args[:width], args[:height]) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/kawaii/physics_entity.rb', line 6 def body @body end |
#geom ⇒ Object
Returns the value of attribute geom.
6 7 8 |
# File 'lib/kawaii/physics_entity.rb', line 6 def geom @geom end |
#shape ⇒ Object
Returns the value of attribute shape.
6 7 8 |
# File 'lib/kawaii/physics_entity.rb', line 6 def shape @shape end |
Instance Method Details
#add_to_space(chipmunk_space) ⇒ Object
18 19 20 |
# File 'lib/kawaii/physics_entity.rb', line 18 def add_to_space chipmunk_space # TODO: check if body is static etc... end |
#remove_from_space(chipmunk_space) ⇒ Object
22 23 |
# File 'lib/kawaii/physics_entity.rb', line 22 def remove_from_space chipmunk_space end |