Box2DX.Dynamics.World.CreateBody C# (CSharp) Method

CreateBody() public method

Create a rigid body given a definition. No reference to the definition is retained. @warning This function is locked during callbacks.
public CreateBody ( BodyDef def ) : Body
def BodyDef
return Body
        public Body CreateBody(BodyDef def)
        {
            Box2DXDebug.Assert(_lock == false);
            if (_lock == true)
            {
                return null;
            }

            Body b = new Body(def, this);

            // Add to world doubly linked list.
            b._prev = null;
            b._next = _bodyList;
            if (_bodyList != null)
            {
                _bodyList._prev = b;
            }
            _bodyList = b;
            ++_bodyCount;

            return b;
        }

Usage Example

Example #1
0
        public PhysicsActor(World _world, Vector2 _position, float _angle = 0.0f, bool _isStatic = false)
        {
            BodyDef bodydef = new BodyDef();
            bodydef.Position = _position;
            bodydef.Angle = 0.0f;

            body = _world.CreateBody(bodydef);
        }
All Usage Examples Of Box2DX.Dynamics.World::CreateBody