Point Incrementation

Hi, all!
In my game, I have a very simple iTween call that is called when an enemy is killed. This increments the score by, say, 20 points. It gets animated nicely and changes the value.
I like it a lot, but when multiple enemies are destroyed at the same time (explosion), only the point value for the first enemy gets incremented.

Say 3 enemies are killed almost simultaneously that all have a payoff of 20 points. Only 20 points will be added as opposed to 60.

Is there a way I can work around this?

Any ideas are much appreciated.

Thanks!- YA

One solution:

  • iTween has the “oncomplete” and “oncompletetarget” hash values that allow you to setup a callback when an iTween completes. You set a boolean (like bScoring) to true when you launch the iTween, and to false when you get the oncomplete callback.
  • You setup a variable that accrues new points.
  • In Update() if your bRunning is false and there are points to be scored you, 1) set bRunning to true, subtract 20 points, and launch the next iTween.

This way you will get iTweens running in sequence.