Class: RigidCircle

RigidCircle(xf, radius) → {RigidCircle}

Defines a rigid circle shape supported by the physics systems

Found in Chapter 9, page 542 of the textbook

Examples: 9.1 Rigid Shape and Bounds, 9.2 Circle Collisions and Collision Info, 9.6 Collision Position Correction, 9.9 Physics Presets

Constructor

new RigidCircle(xf, radius) → {RigidCircle}

Parameters:
Name Type Description
xf Transform the Transform for this RigidCircle
radius float radius of the circle
Source:
Returns:
a new RigidCircle instance
Type
RigidCircle

Extends

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
Inherited From:
Source:

boundTest(otherShape) → {boolean}

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

collideCircCirc(c1, c2, collisionInfo) → {boolean}

Tests for collision between two RigidCircles
Parameters:
Name Type Description
c1 RigidCircle the first RigidCircle involved
c2 RigidCircle the second RigidCircle involved
collisionInfo CollisionInfo record of the collision and its resolution
Source:
Returns:
true if a collision occured
Type
boolean

collisionTest(otherShape, collisionInfo) → {boolean}

Tests for collision between this RigidCircle and another RigidShape
Parameters:
Name Type Description
otherShape RigidShape the other shape to test for collision
collisionInfo CollisionInfo record of the collision and its resolution
Source:
Returns:
true if a collision occured
Type
boolean

draw(aCamera)

Draw this RigidCircle to aCamera
Parameters:
Name Type Description
aCamera Camera the Camera to draw to
Overrides:
Source:

flipVelocity()

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

getAcceleration() → {vec2}

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

getAngularVelocity() → {float}

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

getBoundRadius() → {float}

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

getCenter() → {vec2}

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

getCurrentState() → {string}

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

getFriction() → {float}

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

getInertia() → {float}

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

getInvMass() → {float}

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

getRadius() → {float}

Returns the radius of this RigidCircle
Source:
Returns:
mRadius - the radius
Type
float

getRestitution() → {float}

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

getType() → {string}

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

getVelocity() → {vec2}

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

incShapeSizeBy(dt)

Add a value to the radius of this RigidCircle
Parameters:
Name Type Description
dt float change in the radius
Source:

setAcceleration(x, y)

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

setAngularVelocity(w)

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

setAngularVelocityDelta(dw)

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

setBoundRadius(r)

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

setFriction(f)

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

setInertia(i)

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

setMass(m)

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

setPosition(x, y)

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

setRestitution(r)

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

setTransform(xf)

Set the Transform for this RigidShape
Parameters:
Name Type Description
xf Transform the Transform
Inherited From:
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
Inherited From:
Source:

toggleDrawBound()

Toggle whether the bounds of this RigidShape are drawn
Inherited From:
Source:

update()

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

updateInertia()

Recalculates the inertia of this RigidCircle
Source:

userSetsState()

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