This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by MikeL

This can be useful if you need to switch between two different phases of a behavior. For example I wanted a building to shake for three seconds then stop shaking for two seconds. Then I wanted to repeat this four times.

//In the building entity's init. 
this.oscillator = new ig.Oscillator([3,2], 4);

//In the buidling's update function
phase = this.oscillator.phase();
if (phase == 0)
    //Make the buidling shake
else if (phase == 1)
    //Wait. Do nothing
    //Finished oscillating. Change to a new state.

Not sure how universally useful this is, but you never know.
Code and more info here.

1 decade ago by Ken

A neat and clean solution. I like it, thanks MikeL
Page 1 of 1
« first « previous next › last »