Jump to content

How to have a method that wait on that a timeline is fully played?


J4N
 Share

Recommended Posts

Hi,

I'm quite new in Phaser, but I've already done a bunch of ionic/angular app.

One of my object has a method that will be called by the main scene:

  powerOff() {
    let easing = 'Cubic'
    let overallDuration = 500
    let visiblePauseDuration = 100

    let flashDuration = overallDuration - visiblePauseDuration / 2

    this.scene.tweens.timeline({
      tweens: [
        {
          targets: this,
          duration: 0,
          tint: 0xff0000,
          ease: easing,
        },
        {
          targets: this,
          duration: flashDuration,
          tint: 0xffffff,
          ease: easing,
        },
        {
          targets: this,
          duration: visiblePauseDuration,
          tint: 0xff0000,
          ease: easing,
        },
        {
          targets: this,
          duration: flashDuration,
          tint: 0xffffff,
          ease: easing,
        },
        {
          targets: this,
          duration: visiblePauseDuration,
          tint: 0xff0000,
          ease: easing,
          onComplete: () => {
            this.scene.sound.play(MainScene.POWER_DOWN)
          },
        },
        {
          targets: this,
          duration: flashDuration,
          tint: 0xf54242,
          ease: easing,
        },
      ],
    })

    this.poweredUp = false
  }

The thing is: I need not exit of this method before the whole thing is completed.

 

Is there some await/async support? Or at least promises ? 

The scene will call this method on a lot of different objects, and I need that they are not done in parallel but sequentially.

 

Thanks a lot!!!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...