API Docs for: 0.5.0
Show:

Circle Class

Extends Shape

Circle shape class.

Constructor

Circle

(
  • [radius=1]
)

Parameters:

  • [radius=1] Number optional

    The radius of this circle

Methods

computeAABB

(
  • out
  • position
  • angle
)

Inherited from Shape but overwritten in src/shapes/Circle.js:52

Parameters:

  • out AABB

    The resulting AABB.

  • position Array
  • angle Number

computeMomentOfInertia

(
  • mass
)
Number

Inherited from Shape but overwritten in src/shapes/Circle.js:26

Parameters:

  • mass Number

Returns:

Number:

updateArea

() Number

Inherited from Shape but overwritten in src/shapes/Circle.js:44

Returns:

Number:

updateBoundingRadius

() Number

Inherited from Shape but overwritten in src/shapes/Circle.js:36

Returns:

Number:

Properties

area

Number

Inherited from Shape: src/shapes/Shape.js:87

Area of this shape.

boundingRadius

Number

Inherited from Shape: src/shapes/Shape.js:34

Bounding circle radius of this shape

collisionGroup

Number

Inherited from Shape: src/shapes/Shape.js:41

Collision group that this shape belongs to (bit mask). See this tutorial.

Example:

// Setup bits for each available group
var PLAYER = Math.pow(2,0),
    ENEMY =  Math.pow(2,1),
    GROUND = Math.pow(2,2)

// Put shapes into their groups
player1Shape.collisionGroup = PLAYER;
player2Shape.collisionGroup = PLAYER;
enemyShape  .collisionGroup = ENEMY;
groundShape .collisionGroup = GROUND;

// Assign groups that each shape collide with.
// Note that the players can collide with ground and enemies, but not with other players.
player1Shape.collisionMask = ENEMY | GROUND;
player2Shape.collisionMask = ENEMY | GROUND;
enemyShape  .collisionMask = PLAYER | GROUND;
groundShape .collisionMask = PLAYER | ENEMY;
// How collision check is done
if(shapeA.collisionGroup & shapeB.collisionMask)!=0 && (shapeB.collisionGroup & shapeA.collisionMask)!=0){
    // The shapes will collide
}

collisionMask

Number

Inherited from Shape: src/shapes/Shape.js:72

Collision mask of this shape. See .collisionGroup.

id

Number

Inherited from Shape: src/shapes/Shape.js:27

Shape object identifier.

material

Material

Inherited from Shape: src/shapes/Shape.js:80

Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead.

radius

Number

The radius of the circle.

sensor

Boolean

Inherited from Shape: src/shapes/Shape.js:94

Set to true if you want this shape to be a sensor. A sensor does not generate contacts, but it still reports contact events. This is good if you want to know if a shape is overlapping another shape, without them generating contacts.