Class: ShakeVec2

ShakeVec2(deltas, freqs, duration) → {ShakeVec2}

Class to model shaking in x and y directions

Found in Chapter 7, page 364 of the textbook

Example: 7.3 Came Shake and Object Oscillation

Constructor

new ShakeVec2(deltas, freqs, duration) → {ShakeVec2}

Parameters:
Name Type Description
deltas vec2 the maximum magnitude of the oscillation
freqs vec2 the frequency of the oscillation in revolutions per cycle
duration integer the number of cycles the oscillation should take
Source:
Returns:
a new ShakeVec2 instance
Type
ShakeVec2

Extends

Methods

_nextDampedHarmonic() → {float}

Internal method to return the next dampened cosine value
Inherited From:
Source:
Returns:
the next dampened cosine value
Type
float

_nextValue() → {float}

Returns the next oscillation magnitude with random sign
Inherited From:
Source:
Returns:
fx - next oscillation magnitude with random sign
Type
float

done() → {boolean}

Returns if the Oscillation has completed
Inherited From:
Source:
Returns:
if duration of this Oscillation has been reached
Type
boolean

getNext() → {Array.<float>}

Returns the next oscillation x and y magnitude with random sign
Overrides:
Source:
Returns:
[x,y] - next x and y oscillation magnitude with random sign
Type
Array.<float>

reStart()

Restarts the shake in the x and y directions
Overrides:
Source: