Class: Box2D
- Inherits:
-
Java::ProcessingBox2d::Box2DProcessing
- Object
- Java::ProcessingBox2d::Box2DProcessing
- Box2D
- Defined in:
- lib/pbox2d/box2d.rb
Overview
rubified interface, also needed for add_listener
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #default_step ⇒ Object
- #defaults ⇒ Object
- #gravity(args) ⇒ Object
- #init_options(args = {}) ⇒ Object
- #step_options(args = {}) ⇒ Object
- #version ⇒ Object
Instance Method Details
#add_listener(listener) ⇒ Object
33 34 35 36 |
# File 'lib/pbox2d/box2d.rb', line 33 def add_listener(listener) # in combination with field accessor we can access protected world world.setContactListener(listener) end |
#default_step ⇒ Object
25 26 27 |
# File 'lib/pbox2d/box2d.rb', line 25 def default_step { time_step: 1.0 / 60, velocity_iter: 8, position_iter: 10 } end |
#defaults ⇒ Object
21 22 23 |
# File 'lib/pbox2d/box2d.rb', line 21 def defaults { scale: 10.0, gravity: [0, -10], warm: true, continuous: true } end |
#gravity(args) ⇒ Object
29 30 31 |
# File 'lib/pbox2d/box2d.rb', line 29 def gravity(args) change_gravity(args.to_java(Java::float)) end |
#init_options(args = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/pbox2d/box2d.rb', line 7 def (args = {}) args = defaults.merge(args) (args[:scale], args[:gravity].to_java(Java::float), args[:warm], args[:continuous] ) end |
#step_options(args = {}) ⇒ Object
16 17 18 19 |
# File 'lib/pbox2d/box2d.rb', line 16 def (args = {}) default_step.merge(args) set_step(args[:time_step], args[:velocity_iter], args[:position_iter]) end |