cocos2d-x
3.3
|
A shape for body. More...
#include <CCPhysicsShape.h>
Public Types | |
enum | Type { UNKNOWN, CIRCLE, BOX, POLYGEN, EDGESEGMENT, EDGEBOX, EDGEPOLYGEN, EDGECHAIN } |
Public Member Functions | |
PhysicsBody * | getBody () const |
Get the body that this shape attaches. More... | |
Type | getType () const |
Return the type of this shape. More... | |
float | getArea () const |
return the area of this shape More... | |
float | getMoment () const |
get moment More... | |
void | setMoment (float moment) |
Set moment, it will change the body's moment this shape attaches. More... | |
void | setTag (int tag) |
int | getTag () const |
float | getMass () const |
get mass More... | |
void | setMass (float mass) |
Set mass, it will change the body's mass this shape attaches. More... | |
float | getDensity () const |
void | setDensity (float density) |
float | getRestitution () const |
void | setRestitution (float restitution) |
float | getFriction () const |
void | setFriction (float friction) |
const PhysicsMaterial & | getMaterial () const |
void | setMaterial (const PhysicsMaterial &material) |
virtual float | calculateDefaultMoment () |
Calculate the default moment value. More... | |
virtual Vec2 | getOffset () |
Get offset. More... | |
virtual Vec2 | getCenter () |
Get center of this shape. More... | |
bool | containsPoint (const Vec2 &point) const |
Test point is in shape or not. More... | |
void | setCategoryBitmask (int bitmask) |
A mask that defines which categories this physics body belongs to. More... | |
int | getCategoryBitmask () const |
void | setContactTestBitmask (int bitmask) |
A mask that defines which categories of bodies cause intersection notifications with this physics body. More... | |
int | getContactTestBitmask () const |
void | setCollisionBitmask (int bitmask) |
A mask that defines which categories of physics bodies can collide with this physics body. More... | |
int | getCollisionBitmask () const |
void | setGroup (int group) |
set the group of body Collision groups let you specify an integral group index. More... | |
int | getGroup () |
![]() | |
void | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
NA NA More... | |
Static Public Member Functions | |
static void | recenterPoints (Vec2 *points, int count, const Vec2 ¢er=Vec2::ZERO) |
move the points to the center More... | |
static Vec2 | getPolyonCenter (const Vec2 *points, int count) |
get center of the polyon points More... | |
Protected Member Functions | |
bool | init (Type type) |
PhysicsBodyInfo * | bodyInfo () const |
PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. More... | |
void | setBody (PhysicsBody *body) |
virtual float | calculateArea () |
calculate the area of this shape More... | |
virtual void | setScale (float scale) |
virtual void | setScale (float scaleX, float scaleY) |
virtual void | setScaleX (float scaleX) |
virtual void | setScaleY (float scaleY) |
virtual void | update (float delta) |
PhysicsShape () | |
virtual | ~PhysicsShape ()=0 |
![]() | |
Ref () | |
Constructor. More... | |
Protected Attributes | |
PhysicsBody * | _body |
PhysicsShapeInfo * | _info |
Type | _type |
float | _area |
float | _mass |
float | _moment |
float | _scaleX |
float | _scaleY |
float | _newScaleX |
float | _newScaleY |
bool | _dirty |
PhysicsMaterial | _material |
int | _tag |
int | _categoryBitmask |
int | _collisionBitmask |
int | _contactTestBitmask |
int | _group |
![]() | |
unsigned int | _referenceCount |
count of references More... | |
Friends | |
class | PhysicsWorld |
class | PhysicsBody |
class | PhysicsJoint |
class | PhysicsDebugDraw |
A shape for body.
You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it.
|
strong |
|
protected |
|
protectedpure virtual |
|
protected |
PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't.
so this method is use for subclasses to catch the bodyInfo from PhysicsBody.
|
inlineprotectedvirtual |
calculate the area of this shape
Reimplemented in PhysicsShapePolygon, and PhysicsShapeCircle.
|
inlinevirtual |
Calculate the default moment value.
Reimplemented in PhysicsShapePolygon, and PhysicsShapeCircle.
bool containsPoint | ( | const Vec2 & | point | ) | const |
Test point is in shape or not.
|
inline |
return the area of this shape
|
inline |
Get the body that this shape attaches.
|
inline |
|
inlinevirtual |
Get center of this shape.
Reimplemented in PhysicsShapeEdgeChain, PhysicsShapeEdgePolygon, PhysicsShapeEdgeSegment, and PhysicsShapePolygon.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
get mass
|
inline |
|
inline |
get moment
|
inlinevirtual |
Get offset.
Reimplemented in PhysicsShapeEdgeBox, PhysicsShapeBox, and PhysicsShapeCircle.
get center of the polyon points
|
inline |
|
inline |
|
inline |
Return the type of this shape.
|
protected |
|
static |
move the points to the center
|
protected |
|
inline |
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).
|
inline |
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).
|
inline |
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 setDensity | ( | float | density | ) |
void setFriction | ( | float | friction | ) |
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
void setMass | ( | float | mass | ) |
Set mass, it will change the body's mass this shape attaches.
void setMaterial | ( | const PhysicsMaterial & | material | ) |
void setMoment | ( | float | moment | ) |
Set moment, it will change the body's moment this shape attaches.
void setRestitution | ( | float | restitution | ) |
|
protectedvirtual |
Reimplemented in PhysicsShapeCircle.
|
protectedvirtual |
Reimplemented in PhysicsShapeCircle.
|
protectedvirtual |
Reimplemented in PhysicsShapeCircle.
|
protectedvirtual |
Reimplemented in PhysicsShapeCircle.
|
inline |
|
protectedvirtual |
Reimplemented in PhysicsShapeEdgeChain, PhysicsShapeEdgePolygon, PhysicsShapeEdgeSegment, PhysicsShapePolygon, and PhysicsShapeCircle.
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |