cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PhysicsWorld Class Reference

An PhysicsWorld object simulates collisions and other physical properties. More...

#include <CCPhysicsWorld.h>

Public Member Functions

virtual void addJoint (PhysicsJoint *joint)
 Adds a joint to this physics world. More...
 
var addJoint ( var joint)
 Adds a joint to this physics world. More...
 
local addJoint ( local joint)
 Adds a joint to this physics world. More...
 
virtual void removeJoint (PhysicsJoint *joint, bool destroy=true)
 Remove a joint from this physics world. More...
 
local removeJoint ( local joint, local true)
 Remove a joint from this physics world. More...
 
virtual void removeAllJoints (bool destroy=true)
 Remove all joints from this physics world. More...
 
virtual void removeBody (PhysicsBody *body)
 Remove a body from this physics world. More...
 
local removeBody ( local body)
 Remove a body from this physics world. More...
 
virtual void removeBody (int tag)
 Remove body by tag. More...
 
var removeBody ( var tag)
 Remove body by tag. More...
 
local removeBody ( local tag)
 Remove body by tag. More...
 
virtual void removeAllBodies ()
 Remove all bodies from physics world. More...
 
void rayCast (PhysicsRayCastCallbackFunc func, const Vec2 &start, const Vec2 &end, void *data)
 Searches for physics shapes that intersects the ray. More...
 
local rayCast ( local func, local start, local end, local data)
 Searches for physics shapes that intersects the ray. More...
 
void queryRect (PhysicsQueryRectCallbackFunc func, const Rect &rect, void *data)
 Searches for physics shapes that contains in the rect. More...
 
void queryPoint (PhysicsQueryPointCallbackFunc func, const Vec2 &point, void *data)
 Searches for physics shapes that contains the point. More...
 
Vector< PhysicsShape * > getShapes (const Vec2 &point) const
 Get phsyics shapes that contains the point. More...
 
PhysicsShapegetShape (const Vec2 &point) const
 Get the nearest phsyics shape that contains the point. More...
 
const Vector< PhysicsBody * > & getAllBodies () const
 Get all the bodys that in this physics world. More...
 
PhysicsBodygetBody (int tag) const
 Get a body by tag. More...
 
local getBody ( local tag)
 Get a body by tag. More...
 
ScenegetScene () const
 Get a scene contain this physics world. More...
 
Vect getGravity () const
 Get the gravity value of this physics world. More...
 
void setGravity (const Vect &gravity)
 set the gravity value of this physics world. More...
 
local setGravity ( local gravity)
 set the gravity value of this physics world. More...
 
void setSpeed (float speed)
 Set the speed of this physics world. More...
 
float getSpeed ()
 Get the speed of this physics world. More...
 
void setUpdateRate (int rate)
 Set the update rate of this physics world. More...
 
local setUpdateRate ( local rate)
 Set the update rate of this physics world. More...
 
int getUpdateRate ()
 Get the update rate of this physics world. More...
 
void setSubsteps (int steps)
 set the number of substeps in an update of the physics world. More...
 
int getSubsteps () const
 Get the number of substeps of this physics world. More...
 
void setDebugDrawMask (int mask)
 Set the debug draw mask of this physics world. More...
 
int getDebugDrawMask ()
 Get the bebug draw mask. More...
 
void setAutoStep (bool autoStep)
 To control the step of physics. More...
 
bool isAutoStep ()
 Get the auto step of this physics world. More...
 
void step (float delta)
 The step for physics world. More...
 

Static Public Attributes

static const int DEBUGDRAW_NONE
 draw nothing More...
 
static const int DEBUGDRAW_SHAPE
 draw shapes More...
 
var DEBUGDRAW_SHAPE
 draw shapes More...
 
local DEBUGDRAW_SHAPE
 draw shapes More...
 
static const int DEBUGDRAW_JOINT
 draw joints More...
 
local DEBUGDRAW_JOINT
 draw joints More...
 
static const int DEBUGDRAW_CONTACT
 draw contact More...
 
var DEBUGDRAW_CONTACT
 draw contact More...
 
local DEBUGDRAW_CONTACT
 draw contact More...
 
static const int DEBUGDRAW_ALL
 draw all More...
 

Protected Member Functions

bool init (Scene &scene)
virtual void addBody (PhysicsBody *body)
var addBody ( var body)
local addBody ( local body)
virtual void addShape (PhysicsShape *shape)
virtual void removeShape (PhysicsShape *shape)
var removeShape ( var shape)
local removeShape ( local shape)
virtual void update (float delta, bool userCall=false)
local update ( local delta, local false)
virtual void debugDraw ()
virtual int collisionBeginCallback (PhysicsContact &contact)
local collisionBeginCallback ( local contact)
virtual int collisionPreSolveCallback (PhysicsContact &contact)
virtual void collisionPostSolveCallback (PhysicsContact &contact)
local collisionPostSolveCallback ( local contact)
virtual void collisionSeparateCallback (PhysicsContact &contact)
var collisionSeparateCallback ( var contact)
local collisionSeparateCallback ( local contact)
virtual void doAddBody (PhysicsBody *body)
virtual void doRemoveBody (PhysicsBody *body)
virtual void doRemoveJoint (PhysicsJoint *joint)
virtual void addBodyOrDelay (PhysicsBody *body)
virtual void removeBodyOrDelay (PhysicsBody *body)
var removeBodyOrDelay ( var body)
local removeBodyOrDelay ( local body)
virtual void updateBodies ()
virtual void updateJoints ()
 PhysicsWorld ()
virtual ~PhysicsWorld ()

Static Protected Member Functions

static PhysicsWorldconstruct (Scene &scene)

Protected Attributes

Vect _gravity
float _speed
int _updateRate
int _updateRateCount
float _updateTime
int _substeps
cpSpace * _cpSpace
bool _updateBodyTransform
Vector< PhysicsBody * > _bodies
std::list< PhysicsJoint * > _joints
var _joints
local _joints
Scene_scene
bool _autoStep
PhysicsDebugDraw_debugDraw
int _debugDrawMask
Vector< PhysicsBody * > _delayAddBodies
var _delayAddBodies
local _delayAddBodies
Vector< PhysicsBody * > _delayRemoveBodies
var _delayRemoveBodies
local _delayRemoveBodies
std::vector< PhysicsJoint * > _delayAddJoints
std::vector< PhysicsJoint * > _delayRemoveJoints
var _delayRemoveJoints
local _delayRemoveJoints

Friends

class Node
class Sprite
class Scene
class Director
class PhysicsBody
class PhysicsShape
class PhysicsJoint
class PhysicsWorldCallback
class PhysicsDebugDraw

Detailed Description

An PhysicsWorld object simulates collisions and other physical properties.

You do not create PhysicsWorld objects directly; instead, you can get it from an Scene object.

Constructor & Destructor Documentation

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

Member Function Documentation

virtual void addBody ( PhysicsBody body)
protectedvirtual
var addBody ( var  body)
protectedvirtual
local addBody ( local  body)
protectedvirtual
virtual void addBodyOrDelay ( PhysicsBody body)
protectedvirtual
var addBodyOrDelay ( var  body)
protectedvirtual
local addBodyOrDelay ( local  body)
protectedvirtual
virtual void addJoint ( PhysicsJoint joint)
virtual

Adds a joint to this physics world.

This joint will be added to this physics world at next frame.

Attention
If this joint is already added to another physics world, it will be removed from that world first and then add to this world.
Parameters
jointA pointer to an existing PhysicsJoint object.
var addJoint ( var  joint)
virtual

Adds a joint to this physics world.

This joint will be added to this physics world at next frame.

Attention
If this joint is already added to another physics world, it will be removed from that world first and then add to this world.
Parameters
jointA pointer to an existing PhysicsJoint object.
local addJoint ( local  joint)
virtual

Adds a joint to this physics world.

This joint will be added to this physics world at next frame.

Attention
If this joint is already added to another physics world, it will be removed from that world first and then add to this world.
Parameters
jointA pointer to an existing PhysicsJoint object.
virtual void addShape ( PhysicsShape shape)
protectedvirtual
var addShape ( var  shape)
protectedvirtual
local addShape ( local  shape)
protectedvirtual
virtual int collisionBeginCallback ( PhysicsContact contact)
protectedvirtual
var collisionBeginCallback ( var  contact)
protectedvirtual
local collisionBeginCallback ( local  contact)
protectedvirtual
virtual void
collisionPostSolveCallback
( PhysicsContact contact)
protectedvirtual
var collisionPostSolveCallback ( var  contact)
protectedvirtual
local collisionPostSolveCallback ( local  contact)
protectedvirtual
virtual int
collisionPreSolveCallback
( PhysicsContact contact)
protectedvirtual
var collisionPreSolveCallback ( var  contact)
protectedvirtual
local collisionPreSolveCallback ( local  contact)
protectedvirtual
virtual void
collisionSeparateCallback
( PhysicsContact contact)
protectedvirtual
var collisionSeparateCallback ( var  contact)
protectedvirtual
local collisionSeparateCallback ( local  contact)
protectedvirtual
static PhysicsWorld* construct ( Scene scene)
staticprotected
var construct ( var  scene)
staticprotected
local construct ( local  scene)
staticprotected
virtual void debugDraw ( )
protectedvirtual
var debugDraw ( )
protectedvirtual
local debugDraw ( )
protectedvirtual
virtual void doAddBody ( PhysicsBody body)
protectedvirtual
var doAddBody ( var  body)
protectedvirtual
local doAddBody ( local  body)
protectedvirtual
virtual void doRemoveBody ( PhysicsBody body)
protectedvirtual
var doRemoveBody ( var  body)
protectedvirtual
local doRemoveBody ( local  body)
protectedvirtual
virtual void doRemoveJoint ( PhysicsJoint joint)
protectedvirtual
var doRemoveJoint ( var  joint)
protectedvirtual
local doRemoveJoint ( local  joint)
protectedvirtual
const Vector<PhysicsBody*>
& getAllBodies
( ) const

Get all the bodys that in this physics world.

Returns
A Vector<PhysicsBody*>& object contains all bodies in this physics world.
var getAllBodies ( )

Get all the bodys that in this physics world.

Returns
A Vector<PhysicsBody*>& object contains all bodies in this physics world.
local getAllBodies ( )

Get all the bodys that in this physics world.

Returns
A Vector<PhysicsBody*>& object contains all bodies in this physics world.
PhysicsBody* getBody ( int  tag) const

Get a body by tag.

Parameters
tagAn interger number that identifies a PhysicsBody object.
Returns
A PhysicsBody object pointer or nullptr if no shapes were found.
var getBody ( var  tag)

Get a body by tag.

Parameters
tagAn interger number that identifies a PhysicsBody object.
Returns
A PhysicsBody object pointer or nullptr if no shapes were found.
local getBody ( local  tag)

Get a body by tag.

Parameters
tagAn interger number that identifies a PhysicsBody object.
Returns
A PhysicsBody object pointer or nullptr if no shapes were found.
int getDebugDrawMask ( )
inline

Get the bebug draw mask.

Returns
An interger number.
var getDebugDrawMask ( )
inline

Get the bebug draw mask.

Returns
An interger number.
local getDebugDrawMask ( )
inline

Get the bebug draw mask.

Returns
An interger number.
Vect getGravity ( ) const
inline

Get the gravity value of this physics world.

Returns
A Vect object.
var getGravity ( )
inline

Get the gravity value of this physics world.

Returns
A Vect object.
local getGravity ( )
inline

Get the gravity value of this physics world.

Returns
A Vect object.
Scene& getScene ( ) const
inline

Get a scene contain this physics world.

Attention
This value is initialized in constructor
Returns
A Scene object reference.
var getScene ( )
inline

Get a scene contain this physics world.

Attention
This value is initialized in constructor
Returns
A Scene object reference.
local getScene ( )
inline

Get a scene contain this physics world.

Attention
This value is initialized in constructor
Returns
A Scene object reference.
PhysicsShape* getShape ( const Vec2 point) const

Get the nearest phsyics shape that contains the point.

Query this physics world at point and return the closest shape.

Parameters
pointA Vec2 object contains the position of the point.
Returns
A PhysicsShape object pointer or nullptr if no shapes were found
var getShape ( var  point)

Get the nearest phsyics shape that contains the point.

Query this physics world at point and return the closest shape.

Parameters
pointA Vec2 object contains the position of the point.
Returns
A PhysicsShape object pointer or nullptr if no shapes were found
local getShape ( local  point)

Get the nearest phsyics shape that contains the point.

Query this physics world at point and return the closest shape.

Parameters
pointA Vec2 object contains the position of the point.
Returns
A PhysicsShape object pointer or nullptr if no shapes were found
Vector<PhysicsShape*> getShapes ( const Vec2 point) const

Get phsyics shapes that contains the point.

All shapes contains the point will be pushed in a Vector<PhysicsShape*> object.

Attention
The point must lie inside a shape.
Parameters
pointA Vec2 object contains the position of the point.
Returns
A Vector<PhysicsShape*> object contains all found PhysicsShape pointer.
var getShapes ( var  point)

Get phsyics shapes that contains the point.

All shapes contains the point will be pushed in a Vector<PhysicsShape*> object.

Attention
The point must lie inside a shape.
Parameters
pointA Vec2 object contains the position of the point.
Returns
A Vector<PhysicsShape*> object contains all found PhysicsShape pointer.
local getShapes ( local  point)

Get phsyics shapes that contains the point.

All shapes contains the point will be pushed in a Vector<PhysicsShape*> object.

Attention
The point must lie inside a shape.
Parameters
pointA Vec2 object contains the position of the point.
Returns
A Vector<PhysicsShape*> object contains all found PhysicsShape pointer.
float getSpeed ( )
inline

Get the speed of this physics world.

Returns
A float number.
var getSpeed ( )
inline

Get the speed of this physics world.

Returns
A float number.
local getSpeed ( )
inline

Get the speed of this physics world.

Returns
A float number.
int getSubsteps ( ) const
inline

Get the number of substeps of this physics world.

Returns
An interger number.
var getSubsteps ( )
inline

Get the number of substeps of this physics world.

Returns
An interger number.
local getSubsteps ( )
inline

Get the number of substeps of this physics world.

Returns
An interger number.
int getUpdateRate ( )
inline

Get the update rate of this physics world.

Returns
An interger number.
var getUpdateRate ( )
inline

Get the update rate of this physics world.

Returns
An interger number.
local getUpdateRate ( )
inline

Get the update rate of this physics world.

Returns
An interger number.
bool init ( Scene scene)
protected
var init ( var  scene)
protected
local init ( local  scene)
protected
bool isAutoStep ( )
inline

Get the auto step of this physics world.

Returns
A bool object.
var isAutoStep ( )
inline

Get the auto step of this physics world.

Returns
A bool object.
local isAutoStep ( )
inline

Get the auto step of this physics world.

Returns
A bool object.
void queryPoint ( PhysicsQueryPointCallbackFunc  func,
const Vec2 point,
void *  data 
)

Searches for physics shapes that contains the point.

Attention
The point must lie inside a shape.
Parameters
funcFunc is called for each shape contains the point.
pointA Vec2 object contains the position of the point.
dataUser defined data, it is passed to func.
var queryPoint ( var  func,
var  point,
var  data 
)

Searches for physics shapes that contains the point.

Attention
The point must lie inside a shape.
Parameters
funcFunc is called for each shape contains the point.
pointA Vec2 object contains the position of the point.
dataUser defined data, it is passed to func.
local queryPoint ( local  func,
local  point,
local  data 
)

Searches for physics shapes that contains the point.

Attention
The point must lie inside a shape.
Parameters
funcFunc is called for each shape contains the point.
pointA Vec2 object contains the position of the point.
dataUser defined data, it is passed to func.
void queryRect ( PhysicsQueryRectCallbackFunc  func,
const Rect rect,
void *  data 
)

Searches for physics shapes that contains in the rect.

Query this physics world to find all shapes overlap rect.

Parameters
funcFunc is called for each shape whose bounding box overlaps rect.
rectA Rect object contains a rectangle's x, y, width and height.
dataUser defined data, it is passed to func.
var queryRect ( var  func,
var  rect,
var  data 
)

Searches for physics shapes that contains in the rect.

Query this physics world to find all shapes overlap rect.

Parameters
funcFunc is called for each shape whose bounding box overlaps rect.
rectA Rect object contains a rectangle's x, y, width and height.
dataUser defined data, it is passed to func.
local queryRect ( local  func,
local  rect,
local  data 
)

Searches for physics shapes that contains in the rect.

Query this physics world to find all shapes overlap rect.

Parameters
funcFunc is called for each shape whose bounding box overlaps rect.
rectA Rect object contains a rectangle's x, y, width and height.
dataUser defined data, it is passed to func.
void rayCast ( PhysicsRayCastCallbackFunc  func,
const Vec2 start,
const Vec2 end,
void *  data 
)

Searches for physics shapes that intersects the ray.

Query this physics world along the line segment from start to end.

Parameters
funcFunc is called for each shape found.
startA Vec2 object contains the begin position of the ray.
endA Vec2 object contains the end position of the ray.
dataUser defined data, it is passed to func.
var rayCast ( var  func,
var  start,
var  end,
var  data 
)

Searches for physics shapes that intersects the ray.

Query this physics world along the line segment from start to end.

Parameters
funcFunc is called for each shape found.
startA Vec2 object contains the begin position of the ray.
endA Vec2 object contains the end position of the ray.
dataUser defined data, it is passed to func.
local rayCast ( local  func,
local  start,
local  end,
local  data 
)

Searches for physics shapes that intersects the ray.

Query this physics world along the line segment from start to end.

Parameters
funcFunc is called for each shape found.
startA Vec2 object contains the begin position of the ray.
endA Vec2 object contains the end position of the ray.
dataUser defined data, it is passed to func.
virtual void removeAllBodies ( )
virtual

Remove all bodies from physics world.

If this world is not locked, those body are removed immediately, otherwise at next frame.

var removeAllBodies ( )
virtual

Remove all bodies from physics world.

If this world is not locked, those body are removed immediately, otherwise at next frame.

local removeAllBodies ( )
virtual

Remove all bodies from physics world.

If this world is not locked, those body are removed immediately, otherwise at next frame.

virtual void removeAllJoints ( bool  destroy = true)
virtual

Remove all joints from this physics world.

Attention
This function is invoked in the destructor of this physics world, you do not use this api in common.
Parameters
destroytrue all joints will be destroyed after remove from this world, false otherwise.
var removeAllJoints ( var  destroy = true)
virtual

Remove all joints from this physics world.

Attention
This function is invoked in the destructor of this physics world, you do not use this api in common.
Parameters
destroytrue all joints will be destroyed after remove from this world, false otherwise.
local removeAllJoints ( local  destroy = true)
virtual

Remove all joints from this physics world.

Attention
This function is invoked in the destructor of this physics world, you do not use this api in common.
Parameters
destroytrue all joints will be destroyed after remove from this world, false otherwise.
virtual void removeBody ( PhysicsBody body)
virtual

Remove a body from this physics world.

If this world is not locked, the body is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
bodyA pointer to an existing PhysicsBody object.
var removeBody ( var  body)
virtual

Remove a body from this physics world.

If this world is not locked, the body is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
bodyA pointer to an existing PhysicsBody object.
local removeBody ( local  body)
virtual

Remove a body from this physics world.

If this world is not locked, the body is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
bodyA pointer to an existing PhysicsBody object.
virtual void removeBody ( int  tag)
virtual

Remove body by tag.

If this world is not locked, the object is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
tagAn interger number that identifies a PhysicsBody object.
var removeBody ( var  tag)
virtual

Remove body by tag.

If this world is not locked, the object is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
tagAn interger number that identifies a PhysicsBody object.
local removeBody ( local  tag)
virtual

Remove body by tag.

If this world is not locked, the object is removed immediately, otherwise at next frame.

Attention
If this body has joints, those joints will be removed also.
Parameters
tagAn interger number that identifies a PhysicsBody object.
virtual void removeBodyOrDelay ( PhysicsBody body)
protectedvirtual
var removeBodyOrDelay ( var  body)
protectedvirtual
local removeBodyOrDelay ( local  body)
protectedvirtual
virtual void removeJoint ( PhysicsJoint joint,
bool  destroy = true 
)
virtual

Remove a joint from this physics world.

If this world is not locked, the joint is removed immediately, otherwise at next frame. If this joint is connected with a body, it will be removed from the body also.

Parameters
jointA pointer to an existing PhysicsJoint object.
destroytrue this joint will be destroyed after remove from this world, false otherwise.
var removeJoint ( var  joint,
var  destroy = true 
)
virtual

Remove a joint from this physics world.

If this world is not locked, the joint is removed immediately, otherwise at next frame. If this joint is connected with a body, it will be removed from the body also.

Parameters
jointA pointer to an existing PhysicsJoint object.
destroytrue this joint will be destroyed after remove from this world, false otherwise.
local removeJoint ( local  joint,
local  destroy = true 
)
virtual

Remove a joint from this physics world.

If this world is not locked, the joint is removed immediately, otherwise at next frame. If this joint is connected with a body, it will be removed from the body also.

Parameters
jointA pointer to an existing PhysicsJoint object.
destroytrue this joint will be destroyed after remove from this world, false otherwise.
virtual void removeShape ( PhysicsShape shape)
protectedvirtual
var removeShape ( var  shape)
protectedvirtual
local removeShape ( local  shape)
protectedvirtual
void setAutoStep ( bool  autoStep)
inline

To control the step of physics.

If you want control it by yourself( fixed-timestep for example ), you can set this to false and call step by yourself.

Attention
If you set auto step to false, setSpeed setSubsteps and setUpdateRate won't work, you need to control the time step by yourself.
Parameters
autoStepA bool object, defaut value is true.
var setAutoStep ( var  autoStep)
inline

To control the step of physics.

If you want control it by yourself( fixed-timestep for example ), you can set this to false and call step by yourself.

Attention
If you set auto step to false, setSpeed setSubsteps and setUpdateRate won't work, you need to control the time step by yourself.
Parameters
autoStepA bool object, defaut value is true.
local setAutoStep ( local  autoStep)
inline

To control the step of physics.

If you want control it by yourself( fixed-timestep for example ), you can set this to false and call step by yourself.

Attention
If you set auto step to false, setSpeed setSubsteps and setUpdateRate won't work, you need to control the time step by yourself.
Parameters
autoStepA bool object, defaut value is true.
void setDebugDrawMask ( int  mask)

Set the debug draw mask of this physics world.

This physics world will draw shapes and joints by DrawNode acoording to mask.

Parameters
maskMask has four value:DEBUGDRAW_NONE, DEBUGDRAW_SHAPE, DEBUGDRAW_JOINT, DEBUGDRAW_CONTACT and DEBUGDRAW_ALL, default is DEBUGDRAW_NONE
var setDebugDrawMask ( var  mask)

Set the debug draw mask of this physics world.

This physics world will draw shapes and joints by DrawNode acoording to mask.

Parameters
maskMask has four value:DEBUGDRAW_NONE, DEBUGDRAW_SHAPE, DEBUGDRAW_JOINT, DEBUGDRAW_CONTACT and DEBUGDRAW_ALL, default is DEBUGDRAW_NONE
local setDebugDrawMask ( local  mask)

Set the debug draw mask of this physics world.

This physics world will draw shapes and joints by DrawNode acoording to mask.

Parameters
maskMask has four value:DEBUGDRAW_NONE, DEBUGDRAW_SHAPE, DEBUGDRAW_JOINT, DEBUGDRAW_CONTACT and DEBUGDRAW_ALL, default is DEBUGDRAW_NONE
void setGravity ( const Vect gravity)

set the gravity value of this physics world.

Parameters
gravityA gravity value of this physics world.
var setGravity ( var  gravity)

set the gravity value of this physics world.

Parameters
gravityA gravity value of this physics world.
local setGravity ( local  gravity)

set the gravity value of this physics world.

Parameters
gravityA gravity value of this physics world.
void setSpeed ( float  speed)
inline

Set the speed of this physics world.

Attention
if you setAutoStep(false), this won't work.
Parameters
speedA float number. Speed is the rate at which the simulation executes. default value is 1.0.
var setSpeed ( var  speed)
inline

Set the speed of this physics world.

Attention
if you setAutoStep(false), this won't work.
Parameters
speedA float number. Speed is the rate at which the simulation executes. default value is 1.0.
local setSpeed ( local  speed)
inline

Set the speed of this physics world.

Attention
if you setAutoStep(false), this won't work.
Parameters
speedA float number. Speed is the rate at which the simulation executes. default value is 1.0.
void setSubsteps ( int  steps)

set the number of substeps in an update of the physics world.

One physics update will be divided into several substeps to increase its accuracy.

Parameters
stepsAn interger number, default value is 1.
var setSubsteps ( var  steps)

set the number of substeps in an update of the physics world.

One physics update will be divided into several substeps to increase its accuracy.

Parameters
stepsAn interger number, default value is 1.
local setSubsteps ( local  steps)

set the number of substeps in an update of the physics world.

One physics update will be divided into several substeps to increase its accuracy.

Parameters
stepsAn interger number, default value is 1.
void setUpdateRate ( int  rate)
inline

Set the update rate of this physics world.

Update rate is the value of EngineUpdateTimes/PhysicsWorldUpdateTimes. Set it higher can improve performance, set it lower can improve accuracy of physics world simulation.

Attention
if you setAutoStep(false), this won't work.
Parameters
rateAn interger number, default value is 1.0.
var setUpdateRate ( var  rate)
inline

Set the update rate of this physics world.

Update rate is the value of EngineUpdateTimes/PhysicsWorldUpdateTimes. Set it higher can improve performance, set it lower can improve accuracy of physics world simulation.

Attention
if you setAutoStep(false), this won't work.
Parameters
rateAn interger number, default value is 1.0.
local setUpdateRate ( local  rate)
inline

Set the update rate of this physics world.

Update rate is the value of EngineUpdateTimes/PhysicsWorldUpdateTimes. Set it higher can improve performance, set it lower can improve accuracy of physics world simulation.

Attention
if you setAutoStep(false), this won't work.
Parameters
rateAn interger number, default value is 1.0.
void step ( float  delta)

The step for physics world.

The times passing for simulate the physics.

Attention
You need to setAutoStep(false) first before it can work.
Parameters
deltaA float number.
var step ( var  delta)

The step for physics world.

The times passing for simulate the physics.

Attention
You need to setAutoStep(false) first before it can work.
Parameters
deltaA float number.
local step ( local  delta)

The step for physics world.

The times passing for simulate the physics.

Attention
You need to setAutoStep(false) first before it can work.
Parameters
deltaA float number.
virtual void update ( float  delta,
bool  userCall = false 
)
protectedvirtual
var update ( var  delta,
var  userCall = false 
)
protectedvirtual
local update ( local  delta,
local  userCall = false 
)
protectedvirtual
virtual void updateBodies ( )
protectedvirtual
var updateBodies ( )
protectedvirtual
local updateBodies ( )
protectedvirtual
virtual void updateJoints ( )
protectedvirtual
var updateJoints ( )
protectedvirtual
local updateJoints ( )
protectedvirtual

Friends And Related Function Documentation

friend class Director
friend
var Director
friend
local Director
friend
friend class Node
friend
var Node
friend
local Node
friend
friend class PhysicsBody
friend
var PhysicsBody
friend
local PhysicsBody
friend
friend class PhysicsDebugDraw
friend
var PhysicsDebugDraw
friend
local PhysicsDebugDraw
friend
friend class PhysicsJoint
friend
var PhysicsJoint
friend
local PhysicsJoint
friend
friend class PhysicsShape
friend
var PhysicsShape
friend
local PhysicsShape
friend
friend class PhysicsWorldCallback
friend
var PhysicsWorldCallback
friend
local PhysicsWorldCallback
friend
friend class Scene
friend
var Scene
friend
local Scene
friend
friend class Sprite
friend
var Sprite
friend
local Sprite
friend

Member Data Documentation

bool _autoStep
protected
var _autoStep
protected
local _autoStep
protected
Vector<PhysicsBody*> _bodies
protected
var _bodies
protected
local _bodies
protected
cpSpace* _cpSpace
protected
var _cpSpace
protected
local _cpSpace
protected
PhysicsDebugDraw* _debugDraw
protected
var _debugDraw
protected
local _debugDraw
protected
int _debugDrawMask
protected
var _debugDrawMask
protected
local _debugDrawMask
protected
Vector<PhysicsBody*>
_delayAddBodies
protected
var _delayAddBodies
protected
local _delayAddBodies
protected
std::vector<PhysicsJoint*>
_delayAddJoints
protected
var _delayAddJoints
protected
local _delayAddJoints
protected
Vector<PhysicsBody*>
_delayRemoveBodies
protected
var _delayRemoveBodies
protected
local _delayRemoveBodies
protected
std::vector<PhysicsJoint*>
_delayRemoveJoints
protected
var _delayRemoveJoints
protected
local _delayRemoveJoints
protected
Vect _gravity
protected
var _gravity
protected
std::list<PhysicsJoint*> _joints
protected
var _joints
protected
local _joints
protected
Scene* _scene
protected
var _scene
protected
local _scene
protected
float _speed
protected
var _speed
protected
local _speed
protected
int _substeps
protected
var _substeps
protected
local _substeps
protected
bool _updateBodyTransform
protected
var _updateBodyTransform
protected
local _updateBodyTransform
protected
int _updateRate
protected
var _updateRate
protected
local _updateRate
protected
int _updateRateCount
protected
var _updateRateCount
protected
local _updateRateCount
protected
float _updateTime
protected
var _updateTime
protected
local _updateTime
protected
const int DEBUGDRAW_ALL
static

draw all

var DEBUGDRAW_ALL
static

draw all

local DEBUGDRAW_ALL
static

draw all

const int DEBUGDRAW_CONTACT
static

draw contact

var DEBUGDRAW_CONTACT
static

draw contact

local DEBUGDRAW_CONTACT
static

draw contact

const int DEBUGDRAW_JOINT
static

draw joints

var DEBUGDRAW_JOINT
static

draw joints

local DEBUGDRAW_JOINT
static

draw joints

const int DEBUGDRAW_NONE
static

draw nothing

var DEBUGDRAW_NONE
static

draw nothing

local DEBUGDRAW_NONE
static

draw nothing

const int DEBUGDRAW_SHAPE
static

draw shapes

var DEBUGDRAW_SHAPE
static

draw shapes

local DEBUGDRAW_SHAPE
static

draw shapes


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