Class b2BodyDef
A body definition: everything a body is created from (pybox2d's b2BodyDef). Reusable.
public class b2BodyDef
- Inheritance
-
b2BodyDef
- Inherited Members
- Extension Methods
Remarks
Reference: Box2D/Dynamics/b2Body.h.
Constructors
b2BodyDef()
A body definition with Box2D's defaults: a static body at the origin.
public b2BodyDef()
b2BodyDef(b2BodyType, b2Vec2?, double, IEnumerable<b2FixtureDef>?, IEnumerable<b2Shape>?, b2FixtureDef?, b2Vec2?, double, double, double, bool, bool, bool, bool, bool, double, object?)
A body definition from pybox2d's keyword arguments; scalars round to float32 as SWIG converts them, and a
refused one raises pybox2d's Failed on kwargs for b2BodyDef.angle: … (its keyword named).
public b2BodyDef(b2BodyType type = b2BodyType.b2_staticBody, b2Vec2? position = null, double angle = 0, IEnumerable<b2FixtureDef>? fixtures = null, IEnumerable<b2Shape>? shapes = null, b2FixtureDef? shapeFixture = null, b2Vec2? linearVelocity = null, double angularVelocity = 0, double linearDamping = 0, double angularDamping = 0, bool allowSleep = true, bool awake = true, bool fixedRotation = false, bool bullet = false, bool active = true, double gravityScale = 1, object? userData = null)
Parameters
typeb2BodyTypeThe body type.
positionb2Vec2?The body origin's world position (origin when null).
angledoubleThe angle in radians.
fixturesIEnumerable<b2FixtureDef>The fixtures CreateBody(b2BodyDef) creates, in order.
shapesIEnumerable<b2Shape>Shapes to create fixtures of with
shapeFixture's material.shapeFixtureb2FixtureDefThe material for
shapes.linearVelocityb2Vec2?The initial linear velocity (zero when null).
angularVelocitydoubleThe initial angular velocity.
linearDampingdoubleThe linear damping.
angularDampingdoubleThe angular damping.
allowSleepboolWhether the body may sleep.
awakeboolWhether it starts awake.
fixedRotationboolWhether it may not rotate.
bulletboolWhether it is a bullet.
activeboolWhether it starts active.
gravityScaledoubleThe gravity scale.
userDataobjectThe user data.
Exceptions
- OverflowError
Thrown for a scalar beyond the float32 range.
Properties
Angle
The angle in radians (stored as float32).
public double Angle { get; set; }
Property Value
AngularVelocity
The initial angular velocity (stored as float32).
public double AngularVelocity { get; set; }
Property Value
Fixtures
The fixtures CreateBody(b2BodyDef) creates on the body, in order (pybox2d's fixtures).
public List<b2FixtureDef> Fixtures { get; }
Property Value
LinearVelocity
The initial linear velocity.
public b2Vec2 LinearVelocity { get; set; }
Property Value
Position
The body origin's world position.
public b2Vec2 Position { get; set; }
Property Value
ShapeFixture
The material for Shapes (pybox2d's shapeFixture; Box2D's defaults when null).
public b2FixtureDef? ShapeFixture { get; set; }
Property Value
Shapes
Shapes CreateBody(b2BodyDef) creates fixtures of, after Fixtures (pybox2d's shapes).
public List<b2Shape> Shapes { get; }
Property Value
Type
The body type.
public b2BodyType Type { get; set; }
Property Value
UserData
The user data.
public object? UserData { get; set; }