cocos2d-x  3.2
 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 the physics world. More...
 
var addJoint ( var joint)
 Adds a joint to the physics world. More...
 
local addJoint ( local joint)
 Adds a joint to the physics world. More...
 
virtual void removeJoint (PhysicsJoint *joint, bool destroy=true)
 Remove a joint from physics world. More...
 
local removeJoint ( local joint, local true)
 Remove a joint from physics world. More...
 
virtual void removeAllJoints (bool destroy=true)
 Remove all joints from physics world. More...
 
virtual void removeBody (PhysicsBody *body)
 Remove a body from physics world. More...
 
local removeBody ( local body)
 Remove a body from physics world. More...
 
virtual void removeBody (int 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...
 
var removeAllBodies ()
 Remove all bodies from physics world. More...
 
local 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...
 
var rayCast ( var func, var start, var end, var 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
 return physics shape that contains the point. More...
 
var getShape ( var point)
 return physics shape that contains the point. More...
 
local getShape ( local point)
 return physics shape that contains the point. More...
 
const Vector< PhysicsBody * > & getAllBodies () const
 Get all the bodys that in the physics world. More...
 
var getAllBodies ()
 Get all the bodys that in the physics world. More...
 
local getAllBodies ()
 Get all the bodys that in the physics world. More...
 
PhysicsBodygetBody (int tag) const
 Get body by tag. More...
 
local getBody ( local tag)
 Get body by tag. More...
 
ScenegetScene () const
 Get scene contain this physics world. More...
 
var getScene ()
 Get scene contain this physics world. More...
 
Vect getGravity () const
 get the gravity value More...
 
void setGravity (const Vect &gravity)
 set the gravity value More...
 
var setGravity ( var gravity)
 set the gravity value More...
 
local setGravity ( local gravity)
 set the gravity value More...
 
void setSpeed (float speed)
 Set the speed of physics world, speed is the rate at which the simulation executes. More...
 
float getSpeed ()
 get the speed of physics world More...
 
void setUpdateRate (int rate)
 set the update rate of physics world, update rate is the value of EngineUpdateTimes/PhysicsWorldUpdateTimes. More...
 
int getUpdateRate ()
 get the update rate More...
 
var getUpdateRate ()
 get the update rate More...
 
local getUpdateRate ()
 get the update rate More...
 
void setDebugDrawMask (int mask)
 set the debug draw mask More...
 
var setDebugDrawMask ( var mask)
 set the debug draw mask More...
 
local setDebugDrawMask ( local mask)
 set the debug draw mask More...
 
int getDebugDrawMask ()
 get the bebug draw mask More...
 

Static Public Attributes

static const int DEBUGDRAW_NONE
 draw nothing More...
 
var DEBUGDRAW_NONE
 draw nothing More...
 
local 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...
 
var 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...
 
var DEBUGDRAW_ALL
 draw all More...
 
local DEBUGDRAW_ALL
 draw all More...
 

Protected Member Functions

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

Static Protected Member Functions

static PhysicsWorldconstruct (Scene &scene)
local construct ( local scene)

Protected Attributes

Vect _gravity
float _speed
var _speed
local _speed
int _updateRate
var _updateRate
local _updateRate
int _updateRateCount
var _updateRateCount
local _updateRateCount
float _updateTime
var _updateTime
local _updateTime
PhysicsWorldInfo_info
var _info
local _info
Vector< PhysicsBody * > _bodies
var _bodies
local _bodies
std::list< PhysicsJoint * > _joints
var _joints
local _joints
Scene_scene
var _scene
local _scene
bool _delayDirty
var _delayDirty
local _delayDirty
PhysicsDebugDraw_debugDraw
var _debugDraw
local _debugDraw
int _debugDrawMask
var _debugDrawMask
local _debugDrawMask
Vector< PhysicsBody * > _delayAddBodies
var _delayAddBodies
local _delayAddBodies
Vector< PhysicsBody * > _delayRemoveBodies
var _delayRemoveBodies
local _delayRemoveBodies
std::vector< PhysicsJoint * > _delayAddJoints
var _delayAddJoints
local _delayAddJoints
std::vector< PhysicsJoint * > _delayRemoveJoints
var _delayRemoveJoints
local _delayRemoveJoints

Friends

class Node
class Sprite
class Scene
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 the physics world.

var addJoint ( var  joint)
virtual

Adds a joint to the physics world.

local addJoint ( local  joint)
virtual

Adds a joint to the physics world.

virtual void addJointOrDelay ( PhysicsJoint joint)
protectedvirtual
var addJointOrDelay ( var  joint)
protectedvirtual
local addJointOrDelay ( local  joint)
protectedvirtual
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 doAddJoint ( PhysicsJoint joint)
protectedvirtual
var doAddJoint ( var  joint)
protectedvirtual
local doAddJoint ( local  joint)
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 the physics world.

var getAllBodies ( )

Get all the bodys that in the physics world.

local getAllBodies ( )

Get all the bodys that in the physics world.

PhysicsBody* getBody ( int  tag) const

Get body by tag.

var getBody ( var  tag)

Get body by tag.

local getBody ( local  tag)

Get body by tag.

int getDebugDrawMask ( )
inline

get the bebug draw mask

var getDebugDrawMask ( )
inline

get the bebug draw mask

local getDebugDrawMask ( )
inline

get the bebug draw mask

Vect getGravity ( ) const
inline

get the gravity value

var getGravity ( )
inline

get the gravity value

local getGravity ( )
inline

get the gravity value

Scene& getScene ( ) const
inline

Get scene contain this physics world.

var getScene ( )
inline

Get scene contain this physics world.

local getScene ( )
inline

Get scene contain this physics world.

PhysicsShape* getShape ( const Vec2 point) const

return physics shape that contains the point.

var getShape ( var  point)

return physics shape that contains the point.

local getShape ( local  point)

return physics shape that contains the point.

Vector<PhysicsShape*> getShapes ( const Vec2 point) const

Get phsyics shapes that contains the point.

var getShapes ( var  point)

Get phsyics shapes that contains the point.

local getShapes ( local  point)

Get phsyics shapes that contains the point.

float getSpeed ( )
inline

get the speed of physics world

var getSpeed ( )
inline

get the speed of physics world

local getSpeed ( )
inline

get the speed of physics world

int getUpdateRate ( )
inline

get the update rate

var getUpdateRate ( )
inline

get the update rate

local getUpdateRate ( )
inline

get the update rate

bool init ( Scene scene)
protected
var init ( var  scene)
protected
local init ( local  scene)
protected
void queryPoint ( PhysicsQueryPointCallbackFunc  func,
const Vec2 point,
void *  data 
)

Searches for physics shapes that contains the point.

var queryPoint ( var  func,
var  point,
var  data 
)

Searches for physics shapes that contains the point.

local queryPoint ( local  func,
local  point,
local  data 
)

Searches for physics shapes that contains the point.

void queryRect ( PhysicsQueryRectCallbackFunc  func,
const Rect rect,
void *  data 
)

Searches for physics shapes that contains in the rect.

var queryRect ( var  func,
var  rect,
var  data 
)

Searches for physics shapes that contains in the rect.

local queryRect ( local  func,
local  rect,
local  data 
)

Searches for physics shapes that contains in the rect.

void rayCast ( PhysicsRayCastCallbackFunc  func,
const Vec2 start,
const Vec2 end,
void *  data 
)

Searches for physics shapes that intersects the ray.

var rayCast ( var  func,
var  start,
var  end,
var  data 
)

Searches for physics shapes that intersects the ray.

local rayCast ( local  func,
local  start,
local  end,
local  data 
)

Searches for physics shapes that intersects the ray.

virtual void removeAllBodies ( )
virtual

Remove all bodies from physics world.

var removeAllBodies ( )
virtual

Remove all bodies from physics world.

local removeAllBodies ( )
virtual

Remove all bodies from physics world.

virtual void removeAllJoints ( bool  destroy = true)
virtual

Remove all joints from physics world.

var removeAllJoints ( var  destroy = true)
virtual

Remove all joints from physics world.

local removeAllJoints ( local  destroy = true)
virtual

Remove all joints from physics world.

virtual void removeBody ( PhysicsBody body)
virtual

Remove a body from physics world.

var removeBody ( var  body)
virtual

Remove a body from physics world.

local removeBody ( local  body)
virtual

Remove a body from physics world.

virtual void removeBody ( int  tag)
virtual

Remove body by tag.

var removeBody ( var  tag)
virtual

Remove body by tag.

local removeBody ( local  tag)
virtual

Remove body by tag.

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 physics world.

var removeJoint ( var  joint,
var  destroy = true 
)
virtual

Remove a joint from physics world.

local removeJoint ( local  joint,
local  destroy = true 
)
virtual

Remove a joint from physics world.

virtual void removeJointOrDelay ( PhysicsJoint joint)
protectedvirtual
var removeJointOrDelay ( var  joint)
protectedvirtual
local removeJointOrDelay ( local  joint)
protectedvirtual
virtual void removeShape ( PhysicsShape shape)
protectedvirtual
var removeShape ( var  shape)
protectedvirtual
local removeShape ( local  shape)
protectedvirtual
void setDebugDrawMask ( int  mask)

set the debug draw mask

var setDebugDrawMask ( var  mask)

set the debug draw mask

local setDebugDrawMask ( local  mask)

set the debug draw mask

void setGravity ( const Vect gravity)

set the gravity value

var setGravity ( var  gravity)

set the gravity value

local setGravity ( local  gravity)

set the gravity value

void setSpeed ( float  speed)
inline

Set the speed of physics world, speed is the rate at which the simulation executes.

default value is 1.0

var setSpeed ( var  speed)
inline

Set the speed of physics world, speed is the rate at which the simulation executes.

default value is 1.0

local setSpeed ( local  speed)
inline

Set the speed of physics world, speed is the rate at which the simulation executes.

default value is 1.0

void setUpdateRate ( int  rate)
inline

set the update rate of 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. default value is 1.0

var setUpdateRate ( var  rate)
inline

set the update rate of 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. default value is 1.0

local setUpdateRate ( local  rate)
inline

set the update rate of 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. default value is 1.0

virtual void update ( float  delta)
protectedvirtual
var update ( var  delta)
protectedvirtual
local update ( local  delta)
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 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

Vector<PhysicsBody*> _bodies
protected
var _bodies
protected
local _bodies
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
bool _delayDirty
protected
var _delayDirty
protected
local _delayDirty
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
local _gravity
protected
PhysicsWorldInfo* _info
protected
var _info
protected
local _info
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 _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: