Class: RigidShape

RigidShape(xf) → {RigidShape}

Base class for objects to participate in physics system, extended by RigidCircles and RigidRectangles. Used to control the Transform of another object

Found in Chapter 9, page 534 of the textbook

Examples: 9.1 Rigid Shape and Bounds, 9.6 Collision Position Correction, 9.9 Physics Presets

Constructor

new RigidShape(xf) → {RigidShape}

Parameters:
Name Type Description
xf Transform the Transform for this RigidShape
Source:
Returns:
a new RigidShape instance
Type
RigidShape

Methods

adjustPositionBy(v, delta)

Adjust the position of this RigidShape by moving the position a distance along a specified vector
Parameters:
Name Type Description
v vec2 the [X,Y] direction vector
delta float the distance to move
Source:

boundTest(otherShape) → {boolean}

Test if this RigidShape is overlapping with another RigidShape
Parameters:
Name Type Description
otherShape RigidShape the other RigidShape
Source:
Returns:
true if the two shapes overlap
Type
boolean

draw(aCamera)

Draws this RigidShape to aCamera if bound drawing is enabled
Parameters:
Name Type Description
aCamera Camera the Camera to draw to
Source:

flipVelocity()

Reverse the direction of the velocity vector of this RigidShape
Source:

getAcceleration() → {vec2}

Returns the world coordinate acceleration vector of this RigidShape
Source:
Returns:
mAcceleration - the acceleration vector
Type
vec2

getAngularVelocity() → {float}

Returns the angular velocity of this RigidShape
Source:
Returns:
mAngularVelocity - the angular velocity
Type
float

getBoundRadius() → {float}

Returns the radius of the bounds for this RigidShape
Source:
Returns:
mBoundRadius - the bounding radius
Type
float

getCenter() → {vec2}

Returns the world coordinates of the center of this RigidShape
Source:
Returns:
[X,Y] center point
Type
vec2

getCurrentState() → {string}

Returns a string containing the mass, inertia, friction, and restitution of this RigidShape
Source:
Returns:
- the information string
Type
string

getFriction() → {float}

Returns the friction for this RigidShape
Source:
Returns:
mFriction - the friction
Type
float

getInertia() → {float}

Returns the inertia of this RigidShape
Source:
Returns:
mInertia - the inertia
Type
float

getInvMass() → {float}

Returns the inverse mass of this RigidShape
Source:
Returns:
mInvMass - the inverse mass
Type
float

getRestitution() → {float}

Returns the restitution for this RigidShape
Source:
Returns:
mRestitution - the restitution
Type
float

getType() → {string}

Returns what subtype this RigidShape belongs to
Source:
Returns:
mType - whether this is a RigidCircle or RigidRectangle
Type
string

getVelocity() → {vec2}

Returns the velocity vector of this RigidShape
Source:
Returns:
mVelocity - [X,Y] velocity vector
Type
vec2

setAcceleration(x, y)

Sets the world coordinate acceleration vector of this RigidShape
Parameters:
Name Type Description
x float horizontal acceleration
y float vertical acceleration
Source:

setAngularVelocity(w)

Sets the angular velocity for this RigidShape
Parameters:
Name Type Description
w float the new angular velocity
Source:

setAngularVelocityDelta(dw)

Adds a value to the current angular velocity for this RigidShape
Parameters:
Name Type Description
dw float value to add
Source:

setBoundRadius(r)

Sets the bound radius of this RigidShape
Parameters:
Name Type Description
r float the new bound radius
Source:

setFriction(f)

Sets the friction for this RigidShape
Parameters:
Name Type Description
f float the new friction
Source:

setInertia(i)

Sets the inertia of this RigidShape
Parameters:
Name Type Description
i float the new inertia
Source:

setMass(m)

Sets the mass of this RigidShape
Parameters:
Name Type Description
m float the new mass
Source:

setPosition(x, y)

Set the world coordinate position of this RigidShape
Parameters:
Name Type Description
x float horizontal position
y float vertical position
Source:

setRestitution(r)

Sets the restitution for this RigidShape
Parameters:
Name Type Description
r float the new restitution
Source:

setTransform(xf)

Set the Transform for this RigidShape
Parameters:
Name Type Description
xf Transform the Transform
Source:

setVelocity(x, y)

Set the velocity vector of this RigidShape
Parameters:
Name Type Description
x float horizontal world coordinate velocity
y float vertical world coordinate velocity
Source:

toggleDrawBound()

Toggle whether the bounds of this RigidShape are drawn
Source:

update()

Update this RigidShape changing the position, velocity, and rotation if physics motion is enabled and the RigidShape has mass
Source:

userSetsState()

Based on keyboard input raise or lower the mass, friction, or restitution of this RigidShape
Source: