Class: RubySketch::Shape
- Inherits:
-
Object
- Object
- RubySketch::Shape
- Includes:
- Xot::Inspectable
- Defined in:
- lib/rubysketch/shape.rb
Overview
Shape class for physics calculations.
Direct Known Subclasses
Instance Method Summary collapse
-
#contact(&block) ⇒ nil
Defines contact block.
-
#contact_end(&block) ⇒ nil
Defines contact_end block.
-
#height ⇒ Numeric
(also: #h)
Returns the height of the shape.
-
#sensor=(state) ⇒ Boolean
Set this shape as a sensor object.
-
#sensor? ⇒ Boolean
Returns whether the shape is a sensor or not.
-
#width ⇒ Numeric
(also: #w)
Returns the width of the shape.
Instance Method Details
#contact(&block) ⇒ nil
Defines contact block.
61 62 63 64 65 66 |
# File 'lib/rubysketch/shape.rb', line 61 def contact(&block) @shape.contact_begin do |other| block.call other.instance_variable_get :@owner__ if block end nil end |
#contact_end(&block) ⇒ nil
Defines contact_end block.
77 78 79 80 81 82 |
# File 'lib/rubysketch/shape.rb', line 77 def contact_end(&block) @shape.contact_end do |other| block.call other.instance_variable_get :@owner__ if block end nil end |
#height ⇒ Numeric Also known as: h
Returns the height of the shape.
28 29 30 |
# File 'lib/rubysketch/shape.rb', line 28 def height() @shape.height end |
#sensor=(state) ⇒ Boolean
Set this shape as a sensor object. Sensor object receives contact events, but no collisions.
40 41 42 |
# File 'lib/rubysketch/shape.rb', line 40 def sensor=(state) @shape.sensor = state end |
#sensor? ⇒ Boolean
Returns whether the shape is a sensor or not.
48 49 50 |
# File 'lib/rubysketch/shape.rb', line 48 def sensor?() @shape.sensor? end |
#width ⇒ Numeric Also known as: w
Returns the width of the shape.
20 21 22 |
# File 'lib/rubysketch/shape.rb', line 20 def width() @shape.width end |