Looking for advice for tweenScale

Hello guys, i created event which triggers tween scale for my buttons - what is wrong is that it affect every button that has tweenScale script on, but i would like to make them separately, i want play button to be scaled first and then restart button after a few ms.

here is script for the tween scale, i modified it a little.
I created special attribute which define the object i wanna tween, but the event starts tween in every script, and i cant figure out how to separate it as anywere I use tween.start it triggers tween on every object attached with tweenScale script

If you have multiple tweens listening on the same event, then they will all trigger, if you don’t differentiate between them. If you want to tell specific tween to trigger, you need to make them identify whether this event is addressed to them or to some other tween.

One option is to send additional arguments with an event, which would identify it, for example, an id:

// fire event with id
this.app.fire('tween:start', 2);

// some tween
this.app.on('tween:start', this.start, this);
...
start(id) {
    if (this.id !== id) return;
    ...
}

Another option is to store them in some set, like an array or a map:

this.tweens = new Map();
this.tweens.set(2, tween);
...
// later when you get event
var tween = this.tweens.get(id);
tween.start();
2 Likes