# Chaining multiple tweens

**URL:** <https://phaser.discourse.group/t/chaining-multiple-tweens/960>\
**Category:** Phaser 3\
**Created:** [January 26, 2019, 11:02pm UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960 "2019-01-26T23:02:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [January 26, 2019, 11:02pm UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960/1 "2019-01-26T23:02:19Z")

</div>

It is possible to chain multiple tween in phaser?

I use a [async function in my code,](https://github.com/yandeu/phaser3-typescript-platformer-example/blob/master/src/components/levelText.ts#L17) but I would like to know if there is a phaser way of doing it?

Something like the code below would be useful. Each one of these 3 tweens would run after the onComplete callback was called.

```
this.scene.tweens
 .add({ ...config1})
 .add({ ...config2})
 .add({ ...config3})
```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 27, 2019, 3:14am UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960/2 "2019-01-27T03:14:56Z")

</div>

[https://labs.phaser.io/edit.html?src=src/tweens\timelines\create%20timeline.js](https://labs.phaser.io/edit.html?src=src/tweens%5Ctimelines%5Ccreate%20timeline.js)

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [January 27, 2019, 12:39pm UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960/3 "2019-01-27T12:39:17Z")

</div>

Thanks @samme

Helps to know that there is a `createTimeline()` method on the tweens.

But unfortunately if I want to chain tweens, then some custom functions, then a tween again and another custom function, I run into callback hell.

I think the cleanest way in my case, was to stick with async/await:

```
  private async startTween() {
    await this.tweensAsync({
      targets: this,
      scaleX: 1.5,
      scaleY: 1.5,
      yoyo: true,
      delay: 500,
      duration: 200,
      onComplete: () => console.log('tween 1 completed')
    })

    await this.tweensAsync({
      targets: this,
      y: 10,
      scaleX: 0.5,
      scaleY: 0.5,
      ease: 'Sine.easeInOut',
      delay: 500,
      duration: 400,
      onComplete: () => console.log('tween 2 completed')
    })

    this.setFontSize(28)
    this.setScale(1)

    await this.tweensAsync({
      targets: this,
      alpha: 0,
      delay: 2000,
      duration: 400,
      onComplete: () => console.log('tween 3 completed')
    })

    this.destroy()
  }

```

Here is [my code](https://github.com/yandeu/phaser3-typescript-platformer-example/blob/master/src/components/levelText.ts#L29).

---

<div class="post-metadata">

**Author:** ![adarrshpaul](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/adarrshpaul/32/3714_2.png) [@adarrshpaul](https://phaser.discourse.group/u/adarrshpaul)\
**Post date:** [June 15, 2020, 2:39am UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960/4 "2020-06-15T02:39:56Z")

</div>

Here, is a better way, to do this.  
[Phaser 3 Example](https://labs.phaser.io/edit.html?src=src/tweens%5Ctimelines%5Ccreate%20timeline.js)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [March 26, 2023, 11:36pm UTC](https://phaser.discourse.group/t/chaining-multiple-tweens/960/5 "2023-03-26T23:36:22Z")

</div>

In Phaser v3.60, tween chains have replaced tween timelines.

- [3.60/tweens/chains examples](https://labs.phaser.io/index.html?dir=3.60/tweens/chains/&q=)
- [Phaser.Tweens.TweenManager#chain()](https://newdocs.phaser.io/docs/3.60.0-beta.21/Phaser.Tweens.TweenManager#chain)
- [Phaser.Tweens.TweenChain](https://newdocs.phaser.io/docs/3.60.0-beta.21/Phaser.Tweens.TweenChain)
