Class: Box2D::Joint

Inherits:
Handle show all
Defined in:
lib/box2d/joint.rb

Constant Summary collapse

ID_CLASS =
Native::JointId

Instance Attribute Summary collapse

Attributes inherited from Handle

#id, #world

Instance Method Summary collapse

Methods inherited from Handle

#destroyed?, #eql?, #hash, #valid?

Constructor Details

#initialize(world, id, body_a:, body_b:, user_data: nil) ⇒ Joint

Returns a new instance of Joint.



9
10
11
12
13
14
# File 'lib/box2d/joint.rb', line 9

def initialize(world, id, body_a:, body_b:, user_data: nil)
  super(world, id)
  @body_a = body_a
  @body_b = body_b
  @user_data = user_data
end

Instance Attribute Details

#body_aObject (readonly)

Returns the value of attribute body_a.



7
8
9
# File 'lib/box2d/joint.rb', line 7

def body_a
  @body_a
end

#body_bObject (readonly)

Returns the value of attribute body_b.



7
8
9
# File 'lib/box2d/joint.rb', line 7

def body_b
  @body_b
end

Instance Method Details

#collide_connected=(value) ⇒ Object



38
39
40
41
# File 'lib/box2d/joint.rb', line 38

def collide_connected=(value)
  ensure_valid!
  Native.b2Joint_SetCollideConnected(@id, !!value)
end

#collide_connected?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/box2d/joint.rb', line 33

def collide_connected?
  ensure_valid!
  Native.b2Joint_GetCollideConnected(@id)
end

#constraint_forceObject



43
44
45
46
# File 'lib/box2d/joint.rb', line 43

def constraint_force
  ensure_valid!
  ValueConversion.vec2(Native.b2Joint_GetConstraintForce(@id))
end

#constraint_torqueObject



48
49
50
51
# File 'lib/box2d/joint.rb', line 48

def constraint_torque
  ensure_valid!
  Native.b2Joint_GetConstraintTorque(@id)
end

#destroyObject



26
27
28
29
30
31
# File 'lib/box2d/joint.rb', line 26

def destroy
  ensure_valid!
  Native.b2DestroyJoint(@id)
  invalidate_and_unregister
  true
end

#invalidate_from_body!Object



53
54
55
# File 'lib/box2d/joint.rb', line 53

def invalidate_from_body!
  invalidate_and_unregister
end

#user_dataObject



16
17
18
19
# File 'lib/box2d/joint.rb', line 16

def user_data
  ensure_valid!
  @user_data
end

#user_data=(value) ⇒ Object



21
22
23
24
# File 'lib/box2d/joint.rb', line 21

def user_data=(value)
  ensure_valid!
  @user_data = value
end