PackageBox2D.Collision.Shapes
Classpublic class b2Shape
Subclassesb2CircleShape, b2PolygonShape
Sourceb2Shape.as

A shape is used for collision detection. Shapes are created in b2Body. You can use shape for collision detection before they are attached to the world.

Warning: you cannot reuse shapes.



Public Methods
 MethodDefined by
  
Given a transform, compute the associated axis aligned bounding box for this shape.
b2Shape
  
ComputeMass(massData:b2MassData, density:Number):void
Compute the mass properties of this shape using its dimensions and density.
b2Shape
  
ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number
Compute the volume and centroid of this shape intersected with a half plane
b2Shape
  
Clone the shape
b2Shape
  
GetType():int
Get the type of this shape.
b2Shape
  
RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean
Cast a ray against this shape.
b2Shape
  
Set(other:b2Shape):void
Assign the properties of anther shape to this
b2Shape
  
TestOverlap(shape1:b2Shape, transform1:b2Transform, shape2:b2Shape, transform2:b2Transform):Boolean
[static]
b2Shape
  
TestPoint(xf:b2Transform, p:b2Vec2):Boolean
Test a point for containment in this shape.
b2Shape
Public Constants
 ConstantDefined by
  e_hitCollide : int = 1
[static] Possible return values for TestSegment
b2Shape
  e_missCollide : int = 0
[static] Return value for TestSegment indicating a miss.
b2Shape
  e_startsInsideCollide : int = -1
[static] Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.
b2Shape
Method detail
ComputeAABB()method
public function ComputeAABB(aabb:b2AABB, xf:b2Transform):void

Given a transform, compute the associated axis aligned bounding box for this shape.

Parameters
aabb:b2AABB — returns the axis aligned box.
 
xf:b2Transform — the world transform of the shape.
ComputeMass()method 
public function ComputeMass(massData:b2MassData, density:Number):void

Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

Parameters
massData:b2MassData — returns the mass data for this shape.
 
density:Number
ComputeSubmergedArea()method 
public function ComputeSubmergedArea(normal:b2Vec2, offset:Number, xf:b2Transform, c:b2Vec2):Number

Compute the volume and centroid of this shape intersected with a half plane

Parameters
normal:b2Vec2 — the surface normal
 
offset:Number — the surface offset along normal
 
xf:b2Transform — the shape transform
 
c:b2Vec2 — returns the centroid

Returns
Number — the total volume less than offset along normal
Copy()method 
public function Copy():b2Shape

Clone the shape

Returns
b2Shape
GetType()method 
public function GetType():int

Get the type of this shape. You can use this to down cast to the concrete shape.

Returns
int — the shape type.
RayCast()method 
public function RayCast(output:b2RayCastOutput, input:b2RayCastInput, transform:b2Transform):Boolean

Cast a ray against this shape.

Parameters
output:b2RayCastOutput — the ray-cast results.
 
input:b2RayCastInput — the ray-cast input parameters.
 
transform:b2Transform — the transform to be applied to the shape.

Returns
Boolean
Set()method 
public function Set(other:b2Shape):void

Assign the properties of anther shape to this

Parameters
other:b2Shape
TestOverlap()method 
public static function TestOverlap(shape1:b2Shape, transform1:b2Transform, shape2:b2Shape, transform2:b2Transform):BooleanParameters
shape1:b2Shape
 
transform1:b2Transform
 
shape2:b2Shape
 
transform2:b2Transform

Returns
Boolean
TestPoint()method 
public function TestPoint(xf:b2Transform, p:b2Vec2):Boolean

Test a point for containment in this shape. This only works for convex shapes.

Parameters
xf:b2Transform — the shape world transform.
 
p:b2Vec2 — a point in world coordinates.

Returns
Boolean
Constant detail
e_hitCollideconstant
public static const e_hitCollide:int = 1

Possible return values for TestSegment

e_missCollideconstant 
public static const e_missCollide:int = 0

Return value for TestSegment indicating a miss.

e_startsInsideCollideconstant 
public static const e_startsInsideCollide:int = -1

Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.