Multitarget tween with different parameters

Hello, let’s say I have a tween for a large array of targets. Is there a way to set slightly different parameters for different targets? For example, a random delay, or different alpha depending on (index modulo 2) ?
The only solution I can come up with is making a different tween for each array entry. Or making several different tweens, and assigning a special sub-array to each one. But I’d like to use something efficient yet simple.

1 Like

You can pass functions.

this.tweens.add({
  // …
  alpha: function(target, targetKey, value, targetIndex, totalTargets, tween) {
    return targetIndex % 2;
  },
  delay: function(target, targetKey, value, targetIndex, totalTargets, tween) {
    return Math.random() * 1000;
  }
});

http://labs.phaser.io/edit.html?src=src/tweens\stagger.js

1 Like

Oh, this is great! Thank you