cocos2d-x  3.0alpha1
 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...
 
local addJoint ( local joint)
 Adds a joint to the physics world. More...
 
virtual void removeJoint (PhysicsJoint *joint, bool destroy)
 Removes a joint from the physics world. More...
 
virtual void removeAllJoints (bool destroy)
 Remove all joints from the physics world. More...
 
virtual void removeBody (PhysicsBody *body)
var removeBody ( var body)
local removeBody ( local body)
virtual void removeBody (int tag)
var removeBody ( var tag)
local removeBody ( local tag)
virtual void removeAllBodies ()
void rayCast (PhysicsRayCastCallbackFunc func, const Point &point1, const Point &point2, void *data)
var rayCast ( var func, var point1, var point2, var data)
local rayCast ( local func, local point1, local point2, local data)
void queryRect (PhysicsRectQueryCallbackFunc func, const Rect &rect, void *data)
void queryPoint (PhysicsPointQueryCallbackFunc func, const Point &point, void *data)
local queryPoint ( local func, local point, local data)
ArraygetShapes (const Point &point) const
PhysicsShapegetShape (const Point &point) const
local getShape ( local point)
ArraygetAllBodies () const
PhysicsBodygetBody (int tag) const
local getBody ( local tag)
ScenegetScene () const
 Register a listener to receive contact callbacks. More...
 
Vect getGravity () const
 get the gravity value More...
 
local getGravity ()
 get the gravity value More...
 
void setGravity (const Vect &gravity)
 set the gravity value More...
 
local setGravity ( local gravity)
 set the gravity value More...
 
void setDebugDrawMask (int mask)
 set the debug draw More...
 
var setDebugDrawMask ( var mask)
 set the debug draw More...
 
local setDebugDrawMask ( local mask)
 set the debug draw More...
 
int getDebugDrawMask ()

Static Public Attributes

static const long DEBUGDRAW_NONE = 0x00
var DEBUGDRAW_NONE = 0x00
local DEBUGDRAW_NONE = 0x00
static const long DEBUGDRAW_SHAPE = 0x01
var DEBUGDRAW_SHAPE = 0x01
local DEBUGDRAW_SHAPE = 0x01
static const long DEBUGDRAW_JOINT = 0x02
var DEBUGDRAW_JOINT = 0x02
local DEBUGDRAW_JOINT = 0x02
static const long DEBUGDRAW_CONTACT = 0x04
var DEBUGDRAW_CONTACT = 0x04
local DEBUGDRAW_CONTACT = 0x04
static const long DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT
var DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT
local DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT

Protected Member Functions

bool init (Scene &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)
virtual void debugDraw ()
var 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)
var collisionPostSolveCallback ( var 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)
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)
virtual void removeJointOrDelay (PhysicsJoint *joint)
local removeJointOrDelay ( local joint)
virtual void updateBodies ()
virtual void updateJoints ()
var updateJoints ()
local updateJoints ()
 PhysicsWorld ()
virtual ~PhysicsWorld ()
local ~PhysicsWorld ()

Static Protected Member Functions

static PhysicsWorldconstruct (Scene &scene)

Protected Attributes

Vect _gravity
float _speed
var _speed
local _speed
PhysicsWorldInfo_info
var _info
local _info
Array_bodies
std::list< PhysicsJoint * > _joints
var _joints
local _joints
Scene_scene
bool _delayDirty
var _delayDirty
local _delayDirty
PhysicsDebugDraw_debugDraw
local _debugDraw
int _debugDrawMask
var _debugDrawMask
local _debugDrawMask
Array_delayAddBodies
var _delayAddBodies
local _delayAddBodies
Array_delayRemoveBodies
var _delayRemoveBodies
local _delayRemoveBodies
std::vector< PhysicsJoint * > _delayAddJoints
std::vector< PhysicsJoint * > _delayRemoveJoints
var _delayRemoveJoints
local _delayRemoveJoints

Friends

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
Array* getAllBodies ( ) const
var getAllBodies ( )
local getAllBodies ( )
PhysicsBody* getBody ( int  tag) const
var getBody ( var  tag)
local getBody ( local  tag)
int getDebugDrawMask ( )
inline
var getDebugDrawMask ( )
inline
local getDebugDrawMask ( )
inline
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

Register a listener to receive contact callbacks.

Unregister a listener.

var getScene ( )
inline

Register a listener to receive contact callbacks.

Unregister a listener.

local getScene ( )
inline

Register a listener to receive contact callbacks.

Unregister a listener.

PhysicsShape* getShape ( const Point point) const
var getShape ( var  point)
local getShape ( local  point)
Array* getShapes ( const Point point) const
var getShapes ( var  point)
local getShapes ( local  point)
bool init ( Scene scene)
protected
var init ( var  scene)
protected
local init ( local  scene)
protected
void queryPoint ( PhysicsPointQueryCallbackFunc  func,
const Point point,
void *  data 
)
var queryPoint ( var  func,
var  point,
var  data 
)
local queryPoint ( local  func,
local  point,
local  data 
)
void queryRect ( PhysicsRectQueryCallbackFunc  func,
const Rect rect,
void *  data 
)
var queryRect ( var  func,
var  rect,
var  data 
)
local queryRect ( local  func,
local  rect,
local  data 
)
void rayCast ( PhysicsRayCastCallbackFunc  func,
const Point point1,
const Point point2,
void *  data 
)
var rayCast ( var  func,
var  point1,
var  point2,
var  data 
)
local rayCast ( local  func,
local  point1,
local  point2,
local  data 
)
virtual void removeAllBodies ( )
virtual
var removeAllBodies ( )
virtual
local removeAllBodies ( )
virtual
virtual void removeAllJoints ( bool  destroy)
virtual

Remove all joints from the physics world.

var removeAllJoints ( var  destroy)
virtual

Remove all joints from the physics world.

local removeAllJoints ( local  destroy)
virtual

Remove all joints from the physics world.

virtual void removeBody ( PhysicsBody body)
virtual
var removeBody ( var  body)
virtual
local removeBody ( local  body)
virtual
virtual void removeBody ( int  tag)
virtual
var removeBody ( var  tag)
virtual
local removeBody ( local  tag)
virtual
virtual void removeBodyOrDelay ( PhysicsBody body)
protectedvirtual
var removeBodyOrDelay ( var  body)
protectedvirtual
local removeBodyOrDelay ( local  body)
protectedvirtual
virtual void removeJoint ( PhysicsJoint joint,
bool  destroy 
)
virtual

Removes a joint from the physics world.

var removeJoint ( var  joint,
var  destroy 
)
virtual

Removes a joint from the physics world.

local removeJoint ( local  joint,
local  destroy 
)
virtual

Removes a joint from the 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

var setDebugDrawMask ( var  mask)

set the debug draw

local setDebugDrawMask ( local  mask)

set the debug draw

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

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 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

Array* _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
Array* _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
Array* _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
const long DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT
static
var DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT
static
local DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT
static
const long DEBUGDRAW_CONTACT = 0x04
static
var DEBUGDRAW_CONTACT = 0x04
static
local DEBUGDRAW_CONTACT = 0x04
static
const long DEBUGDRAW_JOINT = 0x02
static
var DEBUGDRAW_JOINT = 0x02
static
local DEBUGDRAW_JOINT = 0x02
static
const long DEBUGDRAW_NONE = 0x00
static
var DEBUGDRAW_NONE = 0x00
static
local DEBUGDRAW_NONE = 0x00
static
const long DEBUGDRAW_SHAPE = 0x01
static
var DEBUGDRAW_SHAPE = 0x01
static
local DEBUGDRAW_SHAPE = 0x01
static

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