new RigidRectangle(xf, width, height) → {RigidRectangle}
Default constructor for the RigidRectangle
Parameters:
Name | Type | Description |
---|---|---|
xf |
Transform | The transform to base the Rigid Rectangle on |
width |
float | The width of the rectangle |
height |
float | The height of the rectangle |
- Source:
Returns:
- Type
- RigidRectangle
Members
collisionInfoR1
Check for collision between RigidRectangle and RigidRectangle
Methods
adjustPositionBy(v, delta)
Adjust the position of the Rigid Rectangle Based on the parameters
Parameters:
Name | Type | Description |
---|---|---|
v |
float | |
delta |
float |
- Source:
checkCircRecVertex(v, circPt, r, info) → {Boolean}
Determines if there is collision between the shapes
Parameters:
Name | Type | Description |
---|---|---|
v |
Array.<float> | The rectangle vertex that is closest to the center of the circle |
circPt |
Array.<float> | The center of the circle |
r |
float | The radius of the circle |
info |
CollisionInfo | Used to store the collision info |
Returns:
If there is collision between the 2 shapes
- Type
- Boolean
collideRectCirc(otherCir, collisionInfo) → {Boolean}
Check for collision between RigidRectangle and Circle
Parameters:
Name | Type | Description |
---|---|---|
otherCir |
Circle | circle to check for collision status against |
collisionInfo |
CollisionInfo | Where the Collision Info is stored |
Returns:
true if collision occurs
- Type
- Boolean
collisionTest(otherShape, collisionInfo) → {Boolean}
Decides on which collision function to call based on the type of shape passed
Parameters:
Name | Type | Description |
---|---|---|
otherShape |
RigidShape | The other shape that's involved |
collisionInfo |
CollisionInfo | Where the collision information is stored |
Returns:
The results of the collision
- Type
- Boolean
computeFaceNormals()
Updates the normals of the faces for the Rigid Rectangle
- Source:
draw(aCamera)
Draws the rectangle
Parameters:
Name | Type | Description |
---|---|---|
aCamera |
Camera | The camera to draw it upon |
- Source:
drawAnEdge(i1, i2, aCamera)
Draws a line
Parameters:
Name | Type | Description |
---|---|---|
i1 |
float | The start point |
i2 |
float | The end point |
aCamera |
Camera | The camera to draw it on |
- Source:
findAxisLeastPenetration(otherRect, collisionInfo) → {Boolean}
Find the shortest axis that overlapping
Parameters:
Name | Type | Description |
---|---|---|
otherRect |
RigidRectangle | Another rectangle that being tested |
collisionInfo |
CollisionInfo | Record the collision information |
Returns:
True if has overlap part in all four directions.
the code is convert from http://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-oriented-rigid-bodies--gamedev-8032
- Type
- Boolean
findSupportPoint(dir, ptOnEdge)
Finds the support point.
Parameters:
Name | Type | Description |
---|---|---|
dir |
type | |
ptOnEdge |
type |
incShapeSizeBy(dt)
Increases the Rigid Rectangle by the number that's passed
Parameters:
Name | Type | Description |
---|---|---|
dt |
float | The number to increase it by |
- Source:
rotateVertices()
Handles verticies for rotated Rigid Rectangles
- Source:
setVertices()
Updates the verticies of the Rigid Rectangle
- Source:
update()
Updates the Rigid Rectangle
- Source:
updateInertia()
Updates the Inertia value
- Source: