Class: Box2D

Inherits:
Java::ProcessingBox2d::Box2DProcessing
  • Object
show all
Defined in:
lib/pbox2d/box2d.rb

Instance Method Summary collapse

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 init_options(args = {})
  scale = args[:scale] || 10.0
  gravity = args[:gravity] || [0, -10.0]
  warm = args[:warm] || true
  continuous = args[:continuous] || true
  set_options(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 step_options(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

#versionObject



30
31
32
# File 'lib/pbox2d/box2d.rb', line 30

def version
  format("pbox2d version %s", Pbox2D::VERSION)
end