Jump to content

Update tween's X/Y onLoop


Bike
 Share

Recommended Posts

Trying to learn Phaser 3 by making a simple card game, I am trying to deal 10 cards slightly offset of each other.
Is this achievable through one tween looping 10 times and updating X/Y values or would I need to consider chaining 10 different tweens or creating/playing in a timedEvent loop. 

The following snippet doesn't appear to change the location the card tweens to on the next play back

 

 tween = this.tweens.add({
            targets: cardSprite,
            x: 200,
            y:400,
            ease: 'Power1',
            duration: 500,
            loop: 10,
            onLoop: tweenOnLoop
        });
    },
    

function tweenOnLoop (tween, targets)
{
tween.x = Phaser.Math.Between(1, 800);
tween.y = Phaser.Math.Between(1, 600);
}

 

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

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