Class: Box2D
- Inherits:
-
Java::ProcessingBox2d::Box2DProcessing
- Object
- Java::ProcessingBox2d::Box2DProcessing
- Box2D
- Defined in:
- lib/pbox2d/box2d.rb
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #gravity(args) ⇒ Object
- #init_options(args = {}) ⇒ Object
- #step_options(args = {}) ⇒ Object
- #version ⇒ Object
Instance Method Details
#add_listener(listener) ⇒ Object
25 26 27 28 |
# File 'lib/pbox2d/box2d.rb', line 25 def add_listener(listener) # in combination with field accessor we can access protected world self.world.setContactListener(listener) end |
#gravity(args) ⇒ Object
21 22 23 |
# File 'lib/pbox2d/box2d.rb', line 21 def gravity(args) change_gravity(args.to_java(Java::float)) end |
#init_options(args = {}) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/pbox2d/box2d.rb', line 6 def (args = {}) scale = args[:scale] || 10.0 gravity = args[:gravity] || [0, -10.0] warm = args[:warm] || true continuous = args[:continuous] || true (scale, gravity.to_java(Java::float), warm, continuous) end |
#step_options(args = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/pbox2d/box2d.rb', line 14 def (args = {}) time_step = args[:time_step] || 1.0 / 60 velocity = args[:velocity_iter] || 8 position = args[:position_iter] || 10 set_step(time_step, velocity, position) end |
#version ⇒ Object
30 31 32 |
# File 'lib/pbox2d/box2d.rb', line 30 def version format("pbox2d version %s", Pbox2D::VERSION) end |