Developer   API   Game Development   Box2D   PhysicsBody

  •  Config(0)
  •  Properties(7)
  •  Methods(27)
  •  Events(1)

PhysicsBody

This class manages PhysicsBody in current PhysicsWorld.

Properties

  • active : Boolean
    Set the active state of the body.
  • angle : Float
    Current body rotation angle in radians.
  • awake : Boolean
    Set to true to put body to sleep, false to wake it. A sleeping body has very low CPU cost.
  • bullet : Boolean
    Flag to treat body like a bullet for continuous collision detection.
  • fixedRotation : Boolean
    Enable / disable rotation of the body.
  • native : b2Body
    Native Instance of PhysicsBody.
  • sleepingAllowed : Boolean
    You can disable sleeping on this body. If you disable sleeping onChar actualy sleeping body, the body will be woken.

Methods

  • applyLinearImpulse(forceX, forceY, pointX, pointY )
    Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity This wakes up sleeping body.
  • applyLinearImpulse( impulseX, impulseY, pointX, pointY )
    Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. If the body is sleeping, this wakes up it.
  • applyAngularImpulse(impulse)
    Apply an angular impulse.
  • applyTorque(torque)
    Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
  • getAngularDamping(impulse) : Float
    Get angular damping of the body.
  • getAngularDamping(damping)
    Set angular damping of the body.
  • getBodyType() : Symbol
    Get type of body.
  • getGravity() : Multivalue
    Get the global gravity.
  • getInertia() : Float
    Get the rotational inertia of the body about the local origin.
  • getLinearDamping() : Multivalue
    Get linear damping of the body.
  • getLinearVelocity() : Multivalue
    Get linear velocity of the center of mass.
  • getLinearVelocityFromLocalPoint(lx, ly) : Multivalue
    Get the world linear velocity of a world point attached to this body.
  • getLinearVelocityFromWorldPoint(wx, wy) : Multivalue
    Get the world velocity of a local point.
  • getLocalCenter() : Multivalue
    Get the local position of the center of mass.
  • getLocalPoint(worldPointX, worldPointY) : Multivalue
    Gets a local point relative to the body's origin given a world point.
  • getLocalVector(worldVectorX, worldVectorY) : Multivalue
    Gets a local vector's x and y from given world vector's x and y coordinates.
  • getMass() : Float
    Get the total mass of the body.
  • getPosition(x, y) : Multivalue
    Get the body's origin position.
  • getWorldCenter() : Multivalue
    Get the world position of the center of mass.
  • getWorldPoint(localPointX, localPointY) : Multivalue
    Get the world coordinates of a point given by the local coordinates.
  • getWorldVector(localVectorX, localVectorY) : Multivalue
    Gets a local vector's x and y from given world vector's x and y coordinates.
  • setGravity(gx, gy) : Multivalue
    Set world’s gravity (separately for x and y axis).
  • setLinearDamping(damping)
    Set linear velocity of the center of mass.
  • setLinearVelocity( x, y )
    Set linear velocity of the center of mass.
  • setPosition(x, y)
    Place body to x, y.
  • setTransform(x, y, angle = 0)
    Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
  • this(world, shape, image, bodyTypeSym, density, friction, bounce) : PhysicsBody
    Create Physics Body into current PhysicsWorld.

Events

  • onDraw : Function
    On Draw event fired when physics body going to be drawn.
API Navigation