public override void update(float t)
{
// waits until enough time has passed for the next shake
if (FloatUtils.EQ(shakeInterval, 0))
{
} // shake every frame!
else if (FloatUtils.Small(t, nextShake))
{
return; // haven't reached the next shake point yet
}
else
{
nextShake += shakeInterval; // proceed with shake this time and increment for next shake goal
}
// calculate the dampening effect, if being used
if (dampening)
{
float dFactor = (1 - t);
amplitude.x = dFactor * startAmplitude.x;
amplitude.y = dFactor * startAmplitude.y;
}
Vector2 newp = new Vector2((Random.Range(0, 100) / 100.0f * amplitude.x * 2) - amplitude.x, (Random.Range(0, 100) / 100.0f * amplitude.y * 2) - amplitude.y);
// simultaneously un-move the last shake and move the next shake
((CCNode)_target).position = ((CCNode)_target).position - last + newp;
// store the current shake value so it can be un-done
last = newp;
}