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.
Not sure how universally useful this is, but you never know.
Code and more info here.
//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 else //Finished oscillating. Change to a new state.
Not sure how universally useful this is, but you never know.
Code and more info here.