cocos2d-x  3.0alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PhysicsBody Class Reference

A body affect by physics. More...

#include <CCPhysicsBody.h>

Inheritance diagram for PhysicsBody:
Object

Public Member Functions

virtual PhysicsShapeaddShape (PhysicsShape *shape, bool addMassAndMoment=true)
void removeShape (PhysicsShape *shape, bool reduceMassAndMoment=true)
void removeShape (int tag, bool reduceMassAndMoment=true)
void removeAllShapes (bool reduceMassAndMoment=true)
ArraygetShapes () const
PhysicsShapegetFirstShape () const
local getFirstShape ()
PhysicsShapegetShape (int tag) const
local getShape ( local tag)
virtual void applyForce (const Vect &force)
 Applies a immediate force to body. More...
 
local applyForce ( local force)
 Applies a immediate force to body. More...
 
virtual void applyForce (const Vect &force, const Point &offset)
 Applies a immediate force to body. More...
 
local applyForce ( local force, local offset)
 Applies a immediate force to body. More...
 
virtual void resetForces ()
 reset all the force applied to body. More...
 
virtual void applyImpulse (const Vect &impulse)
 Applies a continuous force to body. More...
 
var applyImpulse ( var impulse)
 Applies a continuous force to body. More...
 
local applyImpulse ( local impulse)
 Applies a continuous force to body. More...
 
virtual void applyImpulse (const Vect &impulse, const Point &offset)
 Applies a continuous force to body. More...
 
virtual void applyTorque (float torque)
 Applies a torque force to body. More...
 
virtual void setVelocity (const Vect &velocity)
 set the velocity of a body More...
 
local setVelocity ( local velocity)
 set the velocity of a body More...
 
virtual Point getVelocity ()
 get the velocity of a body More...
 
virtual void setAngularVelocity (float velocity)
 set the angular velocity of a body More...
 
local setAngularVelocity ( local velocity)
 set the angular velocity of a body More...
 
virtual Point getVelocityAtLocalPoint (const Point &point)
 get the angular velocity of a body at a local point More...
 
local getVelocityAtLocalPoint ( local point)
 get the angular velocity of a body at a local point More...
 
virtual Point getVelocityAtWorldPoint (const Point &point)
 get the angular velocity of a body at a world point More...
 
var getVelocityAtWorldPoint ( var point)
 get the angular velocity of a body at a world point More...
 
local getVelocityAtWorldPoint ( local point)
 get the angular velocity of a body at a world point More...
 
virtual float getAngularVelocity ()
 get the angular velocity of a body More...
 
virtual void setVelocityLimit (float limit)
 set the max of velocity More...
 
var setVelocityLimit ( var limit)
 set the max of velocity More...
 
local setVelocityLimit ( local limit)
 set the max of velocity More...
 
virtual float getVelocityLimit ()
 get the max of velocity More...
 
virtual void setAngularVelocityLimit (float limit)
 set the max of angular velocity More...
 
virtual float getAngularVelocityLimit ()
 get the max of angular velocity More...
 
void removeFromWorld ()
 remove the body from the world it added to More...
 
PhysicsWorldgetWorld () const
 get the world body added to. More...
 
var getWorld ()
 get the world body added to. More...
 
local getWorld ()
 get the world body added to. More...
 
const std::vector
< PhysicsJoint * > & 
getJoints () const
 get all joints the body have More...
 
local getJoints ()
 get all joints the body have More...
 
NodegetNode () const
 get the sprite the body set to. More...
 
void setCategoryBitmask (int bitmask)
 A mask that defines which categories this physics body belongs to. More...
 
void setContactTestBitmask (int bitmask)
 A mask that defines which categories of bodies cause intersection notifications with this physics body. More...
 
void setCollisionBitmask (int bitmask)
 A mask that defines which categories of physics bodies can collide with this physics body. More...
 
int getCategoryBitmask () const
 get the category bit mask More...
 
int getContactTestBitmask () const
 get the contact test bit mask More...
 
int getCollisionBitmask () const
 get the collision bit mask More...
 
void setGroup (int group)
 set the group of body Collision groups let you specify an integral group index. More...
 
int getGroup () const
 get the group of body More...
 
Point getPosition () const
 get the body position. More...
 
float getRotation () const
 get the body rotation. More...
 
bool isDynamic () const
 test the body is dynamic or not. More...
 
void setDynamic (bool dynamic)
 set dynamic to body. More...
 
local setDynamic ( local dynamic)
 set dynamic to body. More...
 
void setMass (float mass)
 set the body mass. More...
 
float getMass () const
 get the body mass. More...
 
void addMass (float mass)
 add mass to body. More...
 
local addMass ( local mass)
 add mass to body. More...
 
void setMoment (float moment)
 set the body moment of inertia. More...
 
float getMoment (float moment) const
 get the body moment of inertia. More...
 
local getMoment ( local moment)
 get the body moment of inertia. More...
 
void addMoment (float moment)
 add moment of inertia to body. More...
 
float getLinearDamping () const
 get linear damping. More...
 
var getLinearDamping ()
 get linear damping. More...
 
local getLinearDamping ()
 get linear damping. More...
 
void setLinearDamping (float damping)
 set linear damping. More...
 
float getAngularDamping () const
 get angular damping. More...
 
void setAngularDamping (float damping)
 set angular damping. More...
 
bool isResting () const
 whether the body is at rest More...
 
bool isEnabled () const
 whether the body is enabled if the body it isn't enabled, it will not has simulation by world More...
 
void setEnable (bool enable)
 set the enable value. More...
 
local setEnable ( local enable)
 set the enable value. More...
 
bool isRotationEnabled () const
 whether the body can rotation More...
 
void setRotationEnable (bool enable)
 set the body is allow rotation or not More...
 
bool isGravityEnabled () const
 whether this physics body is affected by the physics world’s gravitational force. More...
 
void setGravityEnable (bool enable)
 set the body is affected by the physics world's gravitational force or not. More...
 
int getTag () const
 get the body's tag More...
 
void setTag (int tag)
 set the body's tag More...
 
local setTag ( local tag)
 set the body's tag More...
 
Point world2Local (const Point &point)
 convert the world point to local More...
 
Point local2World (const Point &point)
 convert the local point to world More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)

Static Public Member Functions

static PhysicsBodycreate ()
 create a body with defult mass and moment. More...
 
static PhysicsBodycreate (float mass)
 create a body with mass and defult moment. More...
 
static PhysicsBodycreate (float mass, float moment)
 create a body with mass and moment. More...
 
local create ( local mass, local moment)
 create a body with mass and moment. More...
 
static PhysicsBodycreateCircle (float radius, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, const Point &offset=Point::ZERO)
 Create a body contains a circle shape. More...
 
static PhysicsBodycreateBox (const Size &size, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, const Point &offset=Point::ZERO)
 Create a body contains a box shape. More...
 
static PhysicsBodycreatePolygon (const Point *points, int count, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, const Point &offset=Point::ZERO)
 Create a body contains a polygon shape. More...
 
static PhysicsBodycreateEdgeSegment (const Point &a, const Point &b, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, float border=1)
 Create a body contains a EdgeSegment shape. More...
 
var createEdgeSegment ( var a, var b, var PHYSICSBODY_MATERIAL_DEFAULT, var 1)
 Create a body contains a EdgeSegment shape. More...
 
local createEdgeSegment ( local a, local b, local PHYSICSBODY_MATERIAL_DEFAULT, local 1)
 Create a body contains a EdgeSegment shape. More...
 
static PhysicsBodycreateEdgeBox (const Size &size, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, float border=1, const Point &offset=Point::ZERO)
 Create a body contains a EdgeBox shape. More...
 
static PhysicsBodycreateEdgePolygon (const Point *points, int count, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, float border=1)
 Create a body contains a EdgePolygon shape. More...
 
var createEdgePolygon ( var points, var count, var PHYSICSBODY_MATERIAL_DEFAULT, var 1)
 Create a body contains a EdgePolygon shape. More...
 
local createEdgePolygon ( local points, local count, local PHYSICSBODY_MATERIAL_DEFAULT, local 1)
 Create a body contains a EdgePolygon shape. More...
 
static PhysicsBodycreateEdgeChain (const Point *points, int count, const PhysicsMaterial &material=PHYSICSBODY_MATERIAL_DEFAULT, float border=1)
 Create a body contains a EdgeChain shape. More...
 
local createEdgeChain ( local points, local count, local PHYSICSBODY_MATERIAL_DEFAULT, local 1)
 Create a body contains a EdgeChain shape. More...
 

Protected Member Functions

bool init ()
virtual void setPosition (Point position)
local setPosition ( local position)
virtual void setRotation (float rotation)
local setRotation ( local rotation)
virtual void update (float delta) override
var update ( var delta)
local update ( local delta)
void removeJoint (PhysicsJoint *joint)
 PhysicsBody ()
virtual ~PhysicsBody ()

Protected Attributes

Node_node
std::vector< PhysicsJoint * > _joints
var _joints
local _joints
Array_shapes
PhysicsWorld_world
var _world
local _world
PhysicsBodyInfo_info
local _info
bool _dynamic
bool _enable
bool _rotationEnable
var _rotationEnable
local _rotationEnable
bool _gravityEnable
var _gravityEnable
local _gravityEnable
bool _massDefault
var _massDefault
local _massDefault
bool _momentDefault
var _momentDefault
local _momentDefault
float _mass
float _area
float _density
float _moment
float _linearDamping
var _linearDamping
local _linearDamping
float _angularDamping
var _angularDamping
local _angularDamping
int _tag
int _categoryBitmask
local _categoryBitmask
int _collisionBitmask
var _collisionBitmask
local _collisionBitmask
int _contactTestBitmask
int _group
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 

Friends

class PhysicsWorld
class PhysicsShape
class PhysicsJoint
class Node

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

Detailed Description

A body affect by physics.

it can attach one or more shapes. if you create body with createXXX, it will automatically compute mass and moment with density your specified(which is PHYSICSBODY_MATERIAL_DEFAULT by default, and the density value is 0.1f), and it based on the formular: mass = density * area. if you create body with createEdgeXXX, the mass and moment will be INFINITY by default. and it's a static body. you can change mass and moment with setMass() and setMoment(). and you can change the body to be dynamic or static by use function setDynamic().

Constructor & Destructor Documentation

PhysicsBody ( )
protected
var PhysicsBody ( )
protected
local PhysicsBody ( )
protected
virtual ~PhysicsBody ( )
protectedvirtual
var ~PhysicsBody ( )
protectedvirtual
local ~PhysicsBody ( )
protectedvirtual

Member Function Documentation

void addMass ( float  mass)

add mass to body.

if _mass(mass of the body) == PHYSICS_INFINITY, it remains. if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. if mass == -PHYSICS_INFINITY, _mass will not change. if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) other wise, mass = mass + _mass;

var addMass ( var  mass)

add mass to body.

if _mass(mass of the body) == PHYSICS_INFINITY, it remains. if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. if mass == -PHYSICS_INFINITY, _mass will not change. if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) other wise, mass = mass + _mass;

local addMass ( local  mass)

add mass to body.

if _mass(mass of the body) == PHYSICS_INFINITY, it remains. if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. if mass == -PHYSICS_INFINITY, _mass will not change. if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) other wise, mass = mass + _mass;

void addMoment ( float  moment)

add moment of inertia to body.

if _moment(moment of the body) == PHYSICS_INFINITY, it remains. if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. if moment == -PHYSICS_INFINITY, _moment will not change. if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) other wise, moment = moment + _moment;

var addMoment ( var  moment)

add moment of inertia to body.

if _moment(moment of the body) == PHYSICS_INFINITY, it remains. if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. if moment == -PHYSICS_INFINITY, _moment will not change. if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) other wise, moment = moment + _moment;

local addMoment ( local  moment)

add moment of inertia to body.

if _moment(moment of the body) == PHYSICS_INFINITY, it remains. if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. if moment == -PHYSICS_INFINITY, _moment will not change. if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) other wise, moment = moment + _moment;

virtual PhysicsShape* addShape ( PhysicsShape shape,
bool  addMassAndMoment = true 
)
virtual
var addShape ( var  shape,
var  addMassAndMoment = true 
)
virtual
local addShape ( local  shape,
local  addMassAndMoment = true 
)
virtual
virtual void applyForce ( const Vect force)
virtual

Applies a immediate force to body.

var applyForce ( var  force)
virtual

Applies a immediate force to body.

local applyForce ( local  force)
virtual

Applies a immediate force to body.

virtual void applyForce ( const Vect force,
const Point offset 
)
virtual

Applies a immediate force to body.

var applyForce ( var  force,
var  offset 
)
virtual

Applies a immediate force to body.

local applyForce ( local  force,
local  offset 
)
virtual

Applies a immediate force to body.

virtual void applyImpulse ( const Vect impulse)
virtual

Applies a continuous force to body.

var applyImpulse ( var  impulse)
virtual

Applies a continuous force to body.

local applyImpulse ( local  impulse)
virtual

Applies a continuous force to body.

virtual void applyImpulse ( const Vect impulse,
const Point offset 
)
virtual

Applies a continuous force to body.

var applyImpulse ( var  impulse,
var  offset 
)
virtual

Applies a continuous force to body.

local applyImpulse ( local  impulse,
local  offset 
)
virtual

Applies a continuous force to body.

virtual void applyTorque ( float  torque)
virtual

Applies a torque force to body.

var applyTorque ( var  torque)
virtual

Applies a torque force to body.

local applyTorque ( local  torque)
virtual

Applies a torque force to body.

static PhysicsBody* create ( )
static

create a body with defult mass and moment.

var create ( )
static

create a body with defult mass and moment.

local create ( )
static

create a body with defult mass and moment.

static PhysicsBody* create ( float  mass)
static

create a body with mass and defult moment.

var create ( var  mass)
static

create a body with mass and defult moment.

local create ( local  mass)
static

create a body with mass and defult moment.

static PhysicsBody* create ( float  mass,
float  moment 
)
static

create a body with mass and moment.

var create ( var  mass,
var  moment 
)
static

create a body with mass and moment.

local create ( local  mass,
local  moment 
)
static

create a body with mass and moment.

static PhysicsBody* createBox ( const Size size,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
const Point offset = Point::ZERO 
)
static

Create a body contains a box shape.

var createBox ( var  size,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  offset = Point::ZERO 
)
static

Create a body contains a box shape.

local createBox ( local  size,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  offset = Point::ZERO 
)
static

Create a body contains a box shape.

static PhysicsBody* createCircle ( float  radius,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
const Point offset = Point::ZERO 
)
static

Create a body contains a circle shape.

var createCircle ( var  radius,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  offset = Point::ZERO 
)
static

Create a body contains a circle shape.

local createCircle ( local  radius,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  offset = Point::ZERO 
)
static

Create a body contains a circle shape.

static PhysicsBody* createEdgeBox ( const Size size,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
float  border = 1,
const Point offset = Point::ZERO 
)
static

Create a body contains a EdgeBox shape.

var createEdgeBox ( var  size,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  border = 1,
var  offset = Point::ZERO 
)
static

Create a body contains a EdgeBox shape.

local createEdgeBox ( local  size,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  border = 1,
local  offset = Point::ZERO 
)
static

Create a body contains a EdgeBox shape.

static PhysicsBody* createEdgeChain ( const Point points,
int  count,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
float  border = 1 
)
static

Create a body contains a EdgeChain shape.

var createEdgeChain ( var  points,
var  count,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  border = 1 
)
static

Create a body contains a EdgeChain shape.

local createEdgeChain ( local  points,
local  count,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  border = 1 
)
static

Create a body contains a EdgeChain shape.

static PhysicsBody*
createEdgePolygon
( const Point points,
int  count,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
float  border = 1 
)
static

Create a body contains a EdgePolygon shape.

var createEdgePolygon ( var  points,
var  count,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  border = 1 
)
static

Create a body contains a EdgePolygon shape.

local createEdgePolygon ( local  points,
local  count,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  border = 1 
)
static

Create a body contains a EdgePolygon shape.

static PhysicsBody*
createEdgeSegment
( const Point a,
const Point b,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
float  border = 1 
)
static

Create a body contains a EdgeSegment shape.

var createEdgeSegment ( var  a,
var  b,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  border = 1 
)
static

Create a body contains a EdgeSegment shape.

local createEdgeSegment ( local  a,
local  b,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  border = 1 
)
static

Create a body contains a EdgeSegment shape.

static PhysicsBody* createPolygon ( const Point points,
int  count,
const PhysicsMaterial material = PHYSICSBODY_MATERIAL_DEFAULT,
const Point offset = Point::ZERO 
)
static

Create a body contains a polygon shape.

points is an array of Point structs defining a convex hull with a clockwise winding.

var createPolygon ( var  points,
var  count,
var  material = PHYSICSBODY_MATERIAL_DEFAULT,
var  offset = Point::ZERO 
)
static

Create a body contains a polygon shape.

points is an array of Point structs defining a convex hull with a clockwise winding.

local createPolygon ( local  points,
local  count,
local  material = PHYSICSBODY_MATERIAL_DEFAULT,
local  offset = Point::ZERO 
)
static

Create a body contains a polygon shape.

points is an array of Point structs defining a convex hull with a clockwise winding.

float getAngularDamping ( ) const
inline

get angular damping.

var getAngularDamping ( )
inline

get angular damping.

local getAngularDamping ( )
inline

get angular damping.

virtual float getAngularVelocity ( )
virtual

get the angular velocity of a body

var getAngularVelocity ( )
virtual

get the angular velocity of a body

local getAngularVelocity ( )
virtual

get the angular velocity of a body

virtual float
getAngularVelocityLimit
( )
virtual

get the max of angular velocity

var getAngularVelocityLimit ( )
virtual

get the max of angular velocity

local getAngularVelocityLimit ( )
virtual

get the max of angular velocity

int getCategoryBitmask ( ) const
inline

get the category bit mask

var getCategoryBitmask ( )
inline

get the category bit mask

local getCategoryBitmask ( )
inline

get the category bit mask

int getCollisionBitmask ( ) const
inline

get the collision bit mask

var getCollisionBitmask ( )
inline

get the collision bit mask

local getCollisionBitmask ( )
inline

get the collision bit mask

int getContactTestBitmask ( ) const
inline

get the contact test bit mask

var getContactTestBitmask ( )
inline

get the contact test bit mask

local getContactTestBitmask ( )
inline

get the contact test bit mask

PhysicsShape* getFirstShape ( ) const
inline
var getFirstShape ( )
inline
local getFirstShape ( )
inline
int getGroup ( ) const
inline

get the group of body

var getGroup ( )
inline

get the group of body

local getGroup ( )
inline

get the group of body

const std::vector<PhysicsJoint*>
& getJoints
( ) const
inline

get all joints the body have

var getJoints ( )
inline

get all joints the body have

local getJoints ( )
inline

get all joints the body have

float getLinearDamping ( ) const
inline

get linear damping.

var getLinearDamping ( )
inline

get linear damping.

local getLinearDamping ( )
inline

get linear damping.

float getMass ( ) const
inline

get the body mass.

var getMass ( )
inline

get the body mass.

local getMass ( )
inline

get the body mass.

float getMoment ( float  moment) const
inline

get the body moment of inertia.

var getMoment ( var  moment)
inline

get the body moment of inertia.

local getMoment ( local  moment)
inline

get the body moment of inertia.

Node* getNode ( ) const
inline

get the sprite the body set to.

var getNode ( )
inline

get the sprite the body set to.

local getNode ( )
inline

get the sprite the body set to.

Point getPosition ( ) const

get the body position.

var getPosition ( )

get the body position.

local getPosition ( )

get the body position.

float getRotation ( ) const

get the body rotation.

var getRotation ( )

get the body rotation.

local getRotation ( )

get the body rotation.

PhysicsShape* getShape ( int  tag) const
var getShape ( var  tag)
local getShape ( local  tag)
Array* getShapes ( ) const
inline
var getShapes ( )
inline
local getShapes ( )
inline
int getTag ( ) const
inline

get the body's tag

var getTag ( )
inline

get the body's tag

local getTag ( )
inline

get the body's tag

virtual Point getVelocity ( )
virtual

get the velocity of a body

var getVelocity ( )
virtual

get the velocity of a body

local getVelocity ( )
virtual

get the velocity of a body

virtual Point
getVelocityAtLocalPoint
( const Point point)
virtual

get the angular velocity of a body at a local point

var getVelocityAtLocalPoint ( var  point)
virtual

get the angular velocity of a body at a local point

local getVelocityAtLocalPoint ( local  point)
virtual

get the angular velocity of a body at a local point

virtual Point
getVelocityAtWorldPoint
( const Point point)
virtual

get the angular velocity of a body at a world point

var getVelocityAtWorldPoint ( var  point)
virtual

get the angular velocity of a body at a world point

local getVelocityAtWorldPoint ( local  point)
virtual

get the angular velocity of a body at a world point

virtual float getVelocityLimit ( )
virtual

get the max of velocity

var getVelocityLimit ( )
virtual

get the max of velocity

local getVelocityLimit ( )
virtual

get the max of velocity

PhysicsWorld* getWorld ( ) const
inline

get the world body added to.

var getWorld ( )
inline

get the world body added to.

local getWorld ( )
inline

get the world body added to.

bool init ( )
protected
var init ( )
protected
local init ( )
protected
bool isDynamic ( ) const
inline

test the body is dynamic or not.

a dynamic body will effect with gravity.

var isDynamic ( )
inline

test the body is dynamic or not.

a dynamic body will effect with gravity.

local isDynamic ( )
inline

test the body is dynamic or not.

a dynamic body will effect with gravity.

bool isEnabled ( ) const
inline

whether the body is enabled if the body it isn't enabled, it will not has simulation by world

var isEnabled ( )
inline

whether the body is enabled if the body it isn't enabled, it will not has simulation by world

local isEnabled ( )
inline

whether the body is enabled if the body it isn't enabled, it will not has simulation by world

bool isGravityEnabled ( ) const
inline

whether this physics body is affected by the physics world’s gravitational force.

var isGravityEnabled ( )
inline

whether this physics body is affected by the physics world’s gravitational force.

local isGravityEnabled ( )
inline

whether this physics body is affected by the physics world’s gravitational force.

bool isResting ( ) const

whether the body is at rest

var isResting ( )

whether the body is at rest

local isResting ( )

whether the body is at rest

bool isRotationEnabled ( ) const
inline

whether the body can rotation

var isRotationEnabled ( )
inline

whether the body can rotation

local isRotationEnabled ( )
inline

whether the body can rotation

Point local2World ( const Point point)

convert the local point to world

var local2World ( var  point)

convert the local point to world

local local2World ( local  point)

convert the local point to world

void removeAllShapes ( bool  reduceMassAndMoment = true)
var removeAllShapes ( var  reduceMassAndMoment = true)
local removeAllShapes ( local  reduceMassAndMoment = true)
void removeFromWorld ( )

remove the body from the world it added to

var removeFromWorld ( )

remove the body from the world it added to

local removeFromWorld ( )

remove the body from the world it added to

void removeJoint ( PhysicsJoint joint)
protected
var removeJoint ( var  joint)
protected
local removeJoint ( local  joint)
protected
void removeShape ( PhysicsShape shape,
bool  reduceMassAndMoment = true 
)
var removeShape ( var  shape,
var  reduceMassAndMoment = true 
)
local removeShape ( local  shape,
local  reduceMassAndMoment = true 
)
void removeShape ( int  tag,
bool  reduceMassAndMoment = true 
)
var removeShape ( var  tag,
var  reduceMassAndMoment = true 
)
local removeShape ( local  tag,
local  reduceMassAndMoment = true 
)
virtual void resetForces ( )
virtual

reset all the force applied to body.

var resetForces ( )
virtual

reset all the force applied to body.

local resetForces ( )
virtual

reset all the force applied to body.

void setAngularDamping ( float  damping)
inline

set angular damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

var setAngularDamping ( var  damping)
inline

set angular damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

local setAngularDamping ( local  damping)
inline

set angular damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

virtual void setAngularVelocity ( float  velocity)
virtual

set the angular velocity of a body

var setAngularVelocity ( var  velocity)
virtual

set the angular velocity of a body

local setAngularVelocity ( local  velocity)
virtual

set the angular velocity of a body

virtual void
setAngularVelocityLimit
( float  limit)
virtual

set the max of angular velocity

var setAngularVelocityLimit ( var  limit)
virtual

set the max of angular velocity

local setAngularVelocityLimit ( local  limit)
virtual

set the max of angular velocity

void setCategoryBitmask ( int  bitmask)

A mask that defines which categories this physics body belongs to.

Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions. The default value is 0xFFFFFFFF (all bits set).

var setCategoryBitmask ( var  bitmask)

A mask that defines which categories this physics body belongs to.

Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions. The default value is 0xFFFFFFFF (all bits set).

local setCategoryBitmask ( local  bitmask)

A mask that defines which categories this physics body belongs to.

Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions. The default value is 0xFFFFFFFF (all bits set).

void setCollisionBitmask ( int  bitmask)

A mask that defines which categories of physics bodies can collide with this physics body.

When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity. The default value is 0xFFFFFFFF (all bits set).

var setCollisionBitmask ( var  bitmask)

A mask that defines which categories of physics bodies can collide with this physics body.

When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity. The default value is 0xFFFFFFFF (all bits set).

local setCollisionBitmask ( local  bitmask)

A mask that defines which categories of physics bodies can collide with this physics body.

When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity. The default value is 0xFFFFFFFF (all bits set).

void setContactTestBitmask ( int  bitmask)

A mask that defines which categories of bodies cause intersection notifications with this physics body.

When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in. The default value is 0x00000000 (all bits cleared).

var setContactTestBitmask ( var  bitmask)

A mask that defines which categories of bodies cause intersection notifications with this physics body.

When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in. The default value is 0x00000000 (all bits cleared).

local setContactTestBitmask ( local  bitmask)

A mask that defines which categories of bodies cause intersection notifications with this physics body.

When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in. The default value is 0x00000000 (all bits cleared).

void setDynamic ( bool  dynamic)

set dynamic to body.

a dynamic body will effect with gravity.

var setDynamic ( var  dynamic)

set dynamic to body.

a dynamic body will effect with gravity.

local setDynamic ( local  dynamic)

set dynamic to body.

a dynamic body will effect with gravity.

void setEnable ( bool  enable)

set the enable value.

if the body it isn't enabled, it will not has simulation by world

var setEnable ( var  enable)

set the enable value.

if the body it isn't enabled, it will not has simulation by world

local setEnable ( local  enable)

set the enable value.

if the body it isn't enabled, it will not has simulation by world

void setGravityEnable ( bool  enable)

set the body is affected by the physics world's gravitational force or not.

var setGravityEnable ( var  enable)

set the body is affected by the physics world's gravitational force or not.

local setGravityEnable ( local  enable)

set the body is affected by the physics world's gravitational force or not.

void setGroup ( int  group)

set the group of body Collision groups let you specify an integral group index.

You can have all fixtures with the same group index always collide (positive index) or never collide (negative index) it have high priority than bit masks

var setGroup ( var  group)

set the group of body Collision groups let you specify an integral group index.

You can have all fixtures with the same group index always collide (positive index) or never collide (negative index) it have high priority than bit masks

local setGroup ( local  group)

set the group of body Collision groups let you specify an integral group index.

You can have all fixtures with the same group index always collide (positive index) or never collide (negative index) it have high priority than bit masks

void setLinearDamping ( float  damping)
inline

set linear damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

var setLinearDamping ( var  damping)
inline

set linear damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

local setLinearDamping ( local  damping)
inline

set linear damping.

it is used to simulate fluid or air friction forces on the body. the value is 0.0f to 1.0f.

void setMass ( float  mass)

set the body mass.

Note
if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead.
var setMass ( var  mass)

set the body mass.

Note
if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead.
local setMass ( local  mass)

set the body mass.

Note
if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead.
void setMoment ( float  moment)

set the body moment of inertia.

Note
if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead.
var setMoment ( var  moment)

set the body moment of inertia.

Note
if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead.
local setMoment ( local  moment)

set the body moment of inertia.

Note
if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead.
virtual void setPosition ( Point  position)
protectedvirtual
var setPosition ( var  position)
protectedvirtual
local setPosition ( local  position)
protectedvirtual
virtual void setRotation ( float  rotation)
protectedvirtual
var setRotation ( var  rotation)
protectedvirtual
local setRotation ( local  rotation)
protectedvirtual
void setRotationEnable ( bool  enable)

set the body is allow rotation or not

var setRotationEnable ( var  enable)

set the body is allow rotation or not

local setRotationEnable ( local  enable)

set the body is allow rotation or not

void setTag ( int  tag)
inline

set the body's tag

var setTag ( var  tag)
inline

set the body's tag

local setTag ( local  tag)
inline

set the body's tag

virtual void setVelocity ( const Vect velocity)
virtual

set the velocity of a body

var setVelocity ( var  velocity)
virtual

set the velocity of a body

local setVelocity ( local  velocity)
virtual

set the velocity of a body

virtual void setVelocityLimit ( float  limit)
virtual

set the max of velocity

var setVelocityLimit ( var  limit)
virtual

set the max of velocity

local setVelocityLimit ( local  limit)
virtual

set the max of velocity

virtual void update ( float  delta)
overrideprotectedvirtual

Reimplemented from Object.

var update ( var  delta)
overrideprotectedvirtual

Reimplemented from Object.

local update ( local  delta)
overrideprotectedvirtual

Reimplemented from Object.

Point world2Local ( const Point point)

convert the world point to local

var world2Local ( var  point)

convert the world point to local

local world2Local ( local  point)

convert the world point to local

Friends And Related Function Documentation

friend class Node
friend
var Node
friend
local Node
friend
friend class PhysicsJoint
friend
var PhysicsJoint
friend
local PhysicsJoint
friend
friend class PhysicsShape
friend
var PhysicsShape
friend
local PhysicsShape
friend
friend class PhysicsWorld
friend
var PhysicsWorld
friend
local PhysicsWorld
friend

Member Data Documentation

float _angularDamping
protected
var _angularDamping
protected
local _angularDamping
protected
float _area
protected
var _area
protected
local _area
protected
int _categoryBitmask
protected
var _categoryBitmask
protected
local _categoryBitmask
protected
int _collisionBitmask
protected
var _collisionBitmask
protected
local _collisionBitmask
protected
int _contactTestBitmask
protected
var _contactTestBitmask
protected
local _contactTestBitmask
protected
float _density
protected
var _density
protected
local _density
protected
bool _dynamic
protected
var _dynamic
protected
local _dynamic
protected
bool _enable
protected
var _enable
protected
local _enable
protected
bool _gravityEnable
protected
var _gravityEnable
protected
local _gravityEnable
protected
int _group
protected
var _group
protected
local _group
protected
PhysicsBodyInfo* _info
protected
var _info
protected
local _info
protected
std::vector<PhysicsJoint*> _joints
protected
var _joints
protected
local _joints
protected
float _linearDamping
protected
var _linearDamping
protected
local _linearDamping
protected
float _mass
protected
var _mass
protected
local _mass
protected
bool _massDefault
protected
var _massDefault
protected
local _massDefault
protected
float _moment
protected
var _moment
protected
local _moment
protected
bool _momentDefault
protected
var _momentDefault
protected
local _momentDefault
protected
Node* _node
protected
bool _rotationEnable
protected
var _rotationEnable
protected
local _rotationEnable
protected
Array* _shapes
protected
var _shapes
protected
local _shapes
protected
int _tag
protected
var _tag
protected
local _tag
protected
PhysicsWorld* _world
protected
var _world
protected
local _world
protected

The documentation for this class was generated from the following file: