Tween to next frame in spritesheet

I have a spritesheet with 2 frames and want to make a transition to the second frame and then back to the first.

I made one object for each frame and use a tween timeline:

this.tweens.timeline({
  targets: firstObject,
  tweens: [{ alpha: 0 }, { alpha: 1 }],
  ...
})

this.tweens.timeline({
  targets: secondObject,
  tweens: [{ alpha: 1 }, { alpha: 0 }],
  ...
})

Is there a better solution (maybe use a single tween) or should I keep it that way?

That looks good.

1 Like