Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
PhysicsShapePolygon Class Reference

A polygon shape. More...

Inherits PhysicsShape.

Inherited by PhysicsShapeBox.

Public Member Functions

float calculateDefaultMoment () override
 Calculate the moment for a polygon. More...
 
var calculateDefaultMoment ()
 Calculate the moment for a polygon. More...
 
local calculateDefaultMoment ()
 Calculate the moment for a polygon. More...
 
Vec2 getPoint (int i) const
 Get a point of this polygon's points array. More...
 
var getPoint ( var i)
 Get a point of this polygon's points array. More...
 
local getPoint ( local i)
 Get a point of this polygon's points array. More...
 
void getPoints (Vec2 *outPoints) const
 Get this polygon's points array. More...
 
int getPointsCount () const
 Get this polygon's points array count. More...
 
virtual Vec2 getCenter () override
 Get this polygon's center position. More...
 
local getCenter ()
 Get this polygon's center position. More...
 
- Public Member Functions inherited from PhysicsShape
PhysicsBodygetBody () const
 Get the body that this shape attaches. More...
 
var getBody ()
 Get the body that this shape attaches. More...
 
local getBody ()
 Get the body that this shape attaches. More...
 
Type getType () const
 Return this shape's type. More...
 
local getType ()
 Return this shape's type. More...
 
float getArea () const
 Return this shape's area. More...
 
local getArea ()
 Return this shape's area. More...
 
float getMoment () const
 Get this shape's moment. More...
 
local getMoment ()
 Get this shape's moment. More...
 
void setMoment (float moment)
 Set this shape's moment. More...
 
void setTag (int tag)
 Set this shape's tag. More...
 
int getTag () const
 Get this shape's tag. More...
 
local getTag ()
 Get this shape's tag. More...
 
float getMass () const
 Get the mass of this shape. More...
 
local getMass ()
 Get the mass of this shape. More...
 
void setMass (float mass)
 Set this shape's mass. More...
 
float getDensity () const
 Get this shape's density. More...
 
var getDensity ()
 Get this shape's density. More...
 
local getDensity ()
 Get this shape's density. More...
 
void setDensity (float density)
 Set this shape's density. More...
 
float getRestitution () const
 Get this shape's restitution. More...
 
void setRestitution (float restitution)
 Set this shape's restitution. More...
 
float getFriction () const
 Get this shape's friction. More...
 
void setFriction (float friction)
 Set this shape's friction. More...
 
const PhysicsMaterial & getMaterial () const
 Get this shape's PhysicsMaterial object. More...
 
local getMaterial ()
 Get this shape's PhysicsMaterial object. More...
 
void setMaterial (const PhysicsMaterial &material)
 Set this shape's material. More...
 
local setMaterial ( local material)
 Set this shape's material. More...
 
virtual Vec2 getOffset ()
 Get this shape's position offset. More...
 
var getOffset ()
 Get this shape's position offset. More...
 
local getOffset ()
 Get this shape's position offset. More...
 
bool containsPoint (const Vec2 &point) const
 Test point is inside this shape or not. More...
 
local containsPoint ( local point)
 Test point is inside this shape or not. More...
 
void setCategoryBitmask (int bitmask)
 Set a mask that defines which categories this physics body belongs to. More...
 
int getCategoryBitmask () const
 Get a mask that defines which categories this physics body belongs to. More...
 
void setContactTestBitmask (int bitmask)
 A mask that defines which categories of bodies cause intersection notifications with this physics body. More...
 
int getContactTestBitmask () const
 Get a mask that defines which categories of bodies cause intersection notifications with this physics body. More...
 
void setCollisionBitmask (int bitmask)
 A mask that defines which categories of physics bodies can collide with this physics body. More...
 
local setCollisionBitmask ( local bitmask)
 A mask that defines which categories of physics bodies can collide with this physics body. More...
 
int getCollisionBitmask () const
 Get a mask that defines which categories of physics bodies can collide with this physics body. More...
 
void setGroup (int group)
 Set the group of body. More...
 
int getGroup ()
 Get the group of body. More...
 
var getGroup ()
 Get the group of body. More...
 
local getGroup ()
 Get the group of body. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
local release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Static Public Member Functions

static PhysicsShapePolygoncreate (const Vec2 *points, int count, const PhysicsMaterial &material=PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2 &offset=Vec2::ZERO, float radius=0.0f)
 Creates a PhysicsShapePolygon with specified value. More...
 
local create ( local points, local count, local PHYSICSSHAPE_MATERIAL_DEFAULT, local ZERO, local 0f)
 Creates a PhysicsShapePolygon with specified value. More...
 
static float calculateArea (const Vec2 *points, int count)
 Calculate the area of a polygon with specified value. More...
 
var calculateArea ( var points, var count)
 Calculate the area of a polygon with specified value. More...
 
local calculateArea ( local points, local count)
 Calculate the area of a polygon with specified value. More...
 
static float calculateMoment (float mass, const Vec2 *points, int count, const Vec2 &offset=Vec2::ZERO, float radius=0.0f)
 Calculate the moment of a polygon with specified value. More...
 
local calculateMoment ( local mass, local points, local count, local ZERO, local 0f)
 Calculate the moment of a polygon with specified value. More...
 
- Static Public Member Functions inherited from PhysicsShape
static void recenterPoints (Vec2 *points, int count, const Vec2 &center=Vec2::ZERO)
 Move the points to the center. More...
 
var recenterPoints ( var points, var count, var ZERO)
 Move the points to the center. More...
 
local recenterPoints ( local points, local count, local ZERO)
 Move the points to the center. More...
 
static Vec2 getPolygonCenter (const Vec2 *points, int count)
 Get center of the polygon points. More...
 
local getPolygonCenter ( local points, local count)
 Get center of the polygon points. More...
 
static Vec2 getPolyonCenter (const Vec2 *points, int count)
local getPolyonCenter ( local points, local count)

Additional Inherited Members

- Public Types inherited from PhysicsShape
enum  Type { , POLYGEN = POLYGON, EDGEPOLYGEN = EDGEPOLYGON }
 
- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

A polygon shape.

Member Function Documentation

static PhysicsShapePolygon* create ( const Vec2 points,
int  count,
const PhysicsMaterial &  material = PHYSICSSHAPE_MATERIAL_DEFAULT,
const Vec2 offset = Vec2::ZERO,
float  radius = 0.0f 
)
static

Creates a PhysicsShapePolygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
materialA PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
An autoreleased PhysicsShapePolygon object pointer.
var create ( var  points,
var  count,
var  material = PHYSICSSHAPE_MATERIAL_DEFAULT,
var  offset = Vec2::ZERO,
var  radius = 0.0f 
)
static

Creates a PhysicsShapePolygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
materialA PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
An autoreleased PhysicsShapePolygon object pointer.
local create ( local  points,
local  count,
local  material = PHYSICSSHAPE_MATERIAL_DEFAULT,
local  offset = Vec2::ZERO,
local  radius = 0.0f 
)
static

Creates a PhysicsShapePolygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
materialA PhysicsMaterial object, the default value is PHYSICSSHAPE_MATERIAL_DEFAULT.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
An autoreleased PhysicsShapePolygon object pointer.
static float calculateArea ( const Vec2 points,
int  count 
)
static

Calculate the area of a polygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
Returns
A float number.
var calculateArea ( var  points,
var  count 
)
static

Calculate the area of a polygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
Returns
A float number.
local calculateArea ( local  points,
local  count 
)
static

Calculate the area of a polygon with specified value.

Parameters
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
Returns
A float number.
static float calculateMoment ( float  mass,
const Vec2 points,
int  count,
const Vec2 offset = Vec2::ZERO,
float  radius = 0.0f 
)
static

Calculate the moment of a polygon with specified value.

Parameters
massA float number
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
A float number
var calculateMoment ( var  mass,
var  points,
var  count,
var  offset = Vec2::ZERO,
var  radius = 0.0f 
)
static

Calculate the moment of a polygon with specified value.

Parameters
massA float number
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
A float number
local calculateMoment ( local  mass,
local  points,
local  count,
local  offset = Vec2::ZERO,
local  radius = 0.0f 
)
static

Calculate the moment of a polygon with specified value.

Parameters
massA float number
pointsA Vec2 object pointer, it is an array of Vec2.
countAn integer number, contains the count of the points array.
offsetA Vec2 object, it is the offset from the body's center of gravity in body local coordinates.
Returns
A float number
float calculateDefaultMoment ( )
overridevirtual

Calculate the moment for a polygon.

Returns
A float number.

Reimplemented from PhysicsShape.

var calculateDefaultMoment ( )
overridevirtual

Calculate the moment for a polygon.

Returns
A float number.

Reimplemented from PhysicsShape.

local calculateDefaultMoment ( )
overridevirtual

Calculate the moment for a polygon.

Returns
A float number.

Reimplemented from PhysicsShape.

Vec2 getPoint ( int  i) const

Get a point of this polygon's points array.

Parameters
iA index of this polygon's points array.
Returns
A point value.
var getPoint ( var  i)

Get a point of this polygon's points array.

Parameters
iA index of this polygon's points array.
Returns
A point value.
local getPoint ( local  i)

Get a point of this polygon's points array.

Parameters
iA index of this polygon's points array.
Returns
A point value.
void getPoints ( Vec2 outPoints) const

Get this polygon's points array.

Parameters
outPointsA Vec2 array pointer.
var getPoints ( var  outPoints)

Get this polygon's points array.

Parameters
outPointsA Vec2 array pointer.
local getPoints ( local  outPoints)

Get this polygon's points array.

Parameters
outPointsA Vec2 array pointer.
int getPointsCount ( ) const

Get this polygon's points array count.

Returns
An integer number.
var getPointsCount ( )

Get this polygon's points array count.

Returns
An integer number.
local getPointsCount ( )

Get this polygon's points array count.

Returns
An integer number.
virtual Vec2 getCenter ( )
overridevirtual

Get this polygon's center position.

Returns
A Vec2 object.

Reimplemented from PhysicsShape.

var getCenter ( )
overridevirtual

Get this polygon's center position.

Returns
A Vec2 object.

Reimplemented from PhysicsShape.

local getCenter ( )
overridevirtual

Get this polygon's center position.

Returns
A Vec2 object.

Reimplemented from PhysicsShape.


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