Dart Documentationbox2dBodyDef

BodyDef class

class BodyDef {
 /**
  * The body type: static, kinematic, or dynamic.
  * Note: if a dynamic body would have zero mass, the mass is set to one.
  */
 int type;

 /**
  * The world angle of the body in radians.
  */
 double angle;

 /** User can store whatever they wish in here. */
 Object userData;

 /** The world position of the body. */
 Vector2 position;

 /** Linear velocity of the body in world coordinates. */
 Vector2 linearVelocity;

 /** Angular velocity of the body. */
 double angularVelocity;

 /**
  * If true, the body will be allowed to rotate. Otherwise, its rotation will
  * be fixed.
  */
 bool fixedRotation;

 /** If true, this body is initially sleeping. */
 bool isSleeping;

 /**
  * 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.
  *
  * You should use this flag sparingly since it increases processing time.
  */
 bool bullet;

 /** Set to false to prevent a body from ever falling asleep. */
 bool allowSleep;

 /**
  * Linear damping is used to reduce the linear velocity. The damping
  * parameter can be larger than 1.0 but the damping effect becomes
  * sensitive to the time step when the damping parameter is large.
  */
 double linearDamping;

 /**
  * Angular damping is used to reduce the angular velocity. The
  * damping parameter can be larger than 1.0 but the damping effect
  * becomes sensitive to time step when the damping parameter is large.
  */
 double angularDamping;

 /** Is this body initially awake or asleep? */
 bool awake;

 /** If true, this body starts out active. */
 bool active;

 /**
  * Constructs a new BodyDef with default values.
  */
 BodyDef() :
   userData = null,
   bullet = false,
   type = BodyType.STATIC,
   position = new Vector2.zero(),
   angle = 0.0,
   linearDamping = 0.0,
   angularDamping = 0.0,
   allowSleep = true,
   awake = true,
   fixedRotation = false,
   active = true,
   linearVelocity = new Vector2.zero(),
   angularVelocity = 0.0;
}

Constructors

new BodyDef() #

Constructs a new BodyDef with default values.

BodyDef() :
 userData = null,
 bullet = false,
 type = BodyType.STATIC,
 position = new Vector2.zero(),
 angle = 0.0,
 linearDamping = 0.0,
 angularDamping = 0.0,
 allowSleep = true,
 awake = true,
 fixedRotation = false,
 active = true,
 linearVelocity = new Vector2.zero(),
 angularVelocity = 0.0;

Properties

bool active #

If true, this body starts out active.

bool active

bool allowSleep #

Set to false to prevent a body from ever falling asleep.

bool allowSleep

double angle #

The world angle of the body in radians.

double angle

double angularDamping #

Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to time step when the damping parameter is large.

double angularDamping

double angularVelocity #

Angular velocity of the body.

double angularVelocity

bool awake #

Is this body initially awake or asleep?

bool awake

bool 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.

You should use this flag sparingly since it increases processing time.

bool bullet

bool fixedRotation #

If true, the body will be allowed to rotate. Otherwise, its rotation will be fixed.

bool fixedRotation

bool isSleeping #

If true, this body is initially sleeping.

bool isSleeping

double linearDamping #

Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to the time step when the damping parameter is large.

double linearDamping

Vector2 linearVelocity #

Linear velocity of the body in world coordinates.

Vector2 linearVelocity

Vector2 position #

The world position of the body.

Vector2 position

int type #

The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one.

int type

Object userData #

User can store whatever they wish in here.

Object userData