A shape for body.
More...
Inherits Ref.
Inherited by PhysicsShapeCircle, PhysicsShapeEdgeChain, PhysicsShapeEdgePolygon, PhysicsShapeEdgeSegment, and PhysicsShapePolygon.
|
PhysicsBody * | getBody () const |
| Get the body that this shape attaches.
|
|
Type | getType () const |
| Return this shape's type.
|
|
float | getArea () const |
| Return this shape's area.
|
|
float | getMoment () const |
| Get this shape's moment.
|
|
void | setMoment (float moment) |
| Set this shape's moment.
|
|
void | setTag (int tag) |
| Set this shape's tag.
|
|
int | getTag () const |
| Get this shape's tag.
|
|
float | getMass () const |
| Get the mass of this shape.
|
|
void | setMass (float mass) |
| Set this shape's mass.
|
|
float | getDensity () const |
| Get this shape's density.
|
|
void | setDensity (float density) |
| Set this shape's density.
|
|
float | getRestitution () const |
| Get this shape's restitution.
|
|
void | setRestitution (float restitution) |
| Set this shape's restitution.
|
|
float | getFriction () const |
| Get this shape's friction.
|
|
void | setFriction (float friction) |
| Set this shape's friction.
|
|
const PhysicsMaterial & | getMaterial () const |
| Get this shape's PhysicsMaterial object.
|
|
void | setMaterial (const PhysicsMaterial &material) |
| Set this shape's material.
|
|
virtual float | calculateDefaultMoment () |
| Calculate the default moment value.
|
|
virtual Vec2 | getOffset () |
| Get this shape's position offset.
|
|
virtual Vec2 | getCenter () |
| Get this shape's center position.
|
|
bool | containsPoint (const Vec2 &point) const |
| Test point is inside this shape or not.
|
|
void | setCategoryBitmask (int bitmask) |
| Set a mask that defines which categories this physics body belongs to.
|
|
int | getCategoryBitmask () const |
| Get a mask that defines which categories this physics body belongs to.
|
|
void | setContactTestBitmask (int bitmask) |
| A mask that defines which categories of bodies cause intersection notifications with this physics body.
|
|
int | getContactTestBitmask () const |
| Get a mask that defines which categories of bodies cause intersection notifications with this physics body.
|
|
void | setCollisionBitmask (int bitmask) |
| A mask that defines which categories of physics bodies can collide with this physics body.
|
|
int | getCollisionBitmask () const |
| Get a mask that defines which categories of physics bodies can collide with this physics body.
|
|
void | setGroup (int group) |
| Set the group of body.
|
|
int | getGroup () |
| Get the group of body.
|
|
void | retain () |
| Retains the ownership.
|
|
void | release () |
| Releases the ownership immediately.
|
|
Ref * | autorelease () |
| Releases the ownership sometime soon automatically.
|
|
unsigned int | getReferenceCount () const |
| Returns the Ref's current reference count.
|
|
virtual | ~Ref () |
| Destructor.
|
|
|
unsigned int | _ID |
| object id, ScriptSupport need public _ID
|
|
int | _luaID |
| Lua reference id.
|
|
void * | _scriptObject |
| scriptObject, support for swift
|
|
bool | _rooted |
| When true, it means that the object was already rooted.
|
|
A shape for body.
You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it.
Enumerator |
---|
POLYGEN |
|
EDGEPOLYGEN |
|
Get the body that this shape attaches.
- Returns
- A PhysicsBody object pointer.
Return this shape's type.
- Returns
- A Type object.
Return this shape's area.
- Returns
- A float number.
float getMoment |
( |
| ) |
const |
|
inline |
Get this shape's moment.
- Returns
- A float number.
void setMoment |
( |
float |
moment | ) |
|
Set this shape's moment.
It will change the body's moment this shape attaches.
- Parameters
-
Set this shape's tag.
- Parameters
-
tag | An integer number that identifies a shape object. |
Get this shape's tag.
- Returns
- An integer number.
Get the mass of this shape.
- Returns
- A float number.
void setMass |
( |
float |
mass | ) |
|
Set this shape's mass.
It will change the body's mass this shape attaches.
- Parameters
-
float getDensity |
( |
| ) |
const |
|
inline |
Get this shape's density.
- Returns
- A float number.
void setDensity |
( |
float |
density | ) |
|
Set this shape's density.
It will change the body's mass this shape attaches.
- Parameters
-
float getRestitution |
( |
| ) |
const |
|
inline |
Get this shape's restitution.
- Returns
- A float number.
void setRestitution |
( |
float |
restitution | ) |
|
Set this shape's restitution.
It will change the shape's elasticity.
- Parameters
-
restitution | A float number. |
float getFriction |
( |
| ) |
const |
|
inline |
Get this shape's friction.
- Returns
- A float number.
void setFriction |
( |
float |
friction | ) |
|
Set this shape's friction.
It will change the shape's friction.
- Parameters
-
const PhysicsMaterial& getMaterial |
( |
| ) |
const |
|
inline |
Get this shape's PhysicsMaterial object.
- Returns
- A PhysicsMaterial object reference.
void setMaterial |
( |
const PhysicsMaterial & |
material | ) |
|
Set this shape's material.
It will change the shape's mass, elasticity and friction.
- Parameters
-
material | A PhysicsMaterial object. |
virtual float calculateDefaultMoment |
( |
| ) |
|
|
inlinevirtual |
Calculate the default moment value.
This function should be overridden in inherit classes.
- Returns
- A float number, equals 0.0.
Reimplemented in PhysicsShapePolygon, and PhysicsShapeCircle.
virtual Vec2 getOffset |
( |
| ) |
|
|
inlinevirtual |
virtual Vec2 getCenter |
( |
| ) |
|
|
inlinevirtual |
bool containsPoint |
( |
const Vec2 & |
point | ) |
const |
Test point is inside this shape or not.
- Parameters
-
- Returns
- A bool object.
Move the points to the center.
- Parameters
-
points | A Vec2 object pointer. |
count | An integer number. |
center | A Vec2 object, default value is Vec2(0,0). |
static Vec2 getPolygonCenter |
( |
const Vec2 * |
points, |
|
|
int |
count |
|
) |
| |
|
static |
Get center of the polygon points.
- Parameters
-
points | A Vec2 object pointer. |
count | An integer number. |
- Returns
- A Vec2 object.
void setCategoryBitmask |
( |
int |
bitmask | ) |
|
|
inline |
Set 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.
- Parameters
-
bitmask | An integer number, the default value is 0xFFFFFFFF (all bits set). |
int getCategoryBitmask |
( |
| ) |
const |
|
inline |
Get a mask that defines which categories this physics body belongs to.
- Returns
- An integer number.
void setContactTestBitmask |
( |
int |
bitmask | ) |
|
|
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.
- Parameters
-
bitmask | An integer number, the default value is 0x00000000 (all bits cleared). |
int getContactTestBitmask |
( |
| ) |
const |
|
inline |
Get a mask that defines which categories of bodies cause intersection notifications with this physics body.
- Returns
- An integer number.
void setCollisionBitmask |
( |
int |
bitmask | ) |
|
|
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.
- Parameters
-
bitmask | An integer number, the default value is 0xFFFFFFFF (all bits set). |
int getCollisionBitmask |
( |
| ) |
const |
|
inline |
Get a mask that defines which categories of physics bodies can collide with this physics body.
- Returns
- An integer number.
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).
- Parameters
-
group | An integer number, it have high priority than bit masks. |
Get the group of body.
- Returns
- An integer number.
The documentation for this class was generated from the following file: