NAME
Box2D::b2BodyDef - Holds all the data needed to construct a rigid body.
SYNOPSIS
my $body_def = Box2D::b2BodyDef->new();
$body_def->type( Box2D::b2_dynamicBody );
$body_def->position->Set( $x, $y );
$body_def->angle( $theta );
my $body = $world->CreateBody( $body_def );
DESCRIPTION
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction.
METHODS
new()
This constructor sets the body definition default values.
Returns a Box2D::b2BodyDef
active()
active( $active )
Does this body start out active?
Parameters:
bool
$active
(optional)
Returns a bool
allowSleep()
allowSleep( $allowSleep )
Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.
Parameters:
bool
$allowSleep
(optional)
Returns a bool
angle()
angle( $angle )
The world angle of the body in radians.
Parameters:
float32
$angle
(optional)
Returns a float32
angularDamping()
angularDamping( $angularDamping )
Angular damping is use to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
Parameters:
float32
$angularDamping
(optional)
Returns a float32
angularVelocity()
angularVelocity( $angularVelocity )
The angular velocity of the body.
Parameters:
float32
$angularVelocity
(optional)
Returns a float32
awake()
awake( $awake )
Is this body initially awake or sleeping?
Parameters:
bool
$awake
(optional)
Returns a bool
bullet()
bullet( $bullet )
Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
Warning: You should use this flag sparingly since it increases processing time.
Parameters:
bool
$bullet
(optional)
Returns a bool
fixedRotation()
fixedRotation( $fixedRotation )
Should this body be prevented from rotating? Useful for characters.
Parameters:
bool
$fixedRotation
(optional)
Returns a bool
linearDamping()
linearDamping( $linearDamping )
Linear damping is use to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
Parameters:
float32
$linearDamping
(optional)
Returns a float32
linearVelocity()
linearVelocity( $linearVelocity )
The linear velocity of the body's origin in world co-ordinates.
Parameters:
Box2D::b2Vec2
$linearVelocity
(optional)
Returns a Box2D::b2Vec2
position()
position( $position )
The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes.
Parameters:
Box2D::b2Vec2
$position
(optional)
Returns a Box2D::b2Vec2
type()
type( $type )
The body type: Box2D::b2_staticBody
, Box2D::b2_kinematicBody
, or Box2D::b2_dynamicBody
.
Note: if a dynamic body would have zero mass, the mass is set to one.
Parameters:
Box2D::b2BodyType
$type
(optional)
Returns a Box2D::b2BodyType
userData()
userData( $userData )
Use this to store application specific body data.
Parameters:
scalar
$userData
(optional)
Returns a scalar
SEE ALSO
BUGS
See "BUGS" in Box2D