Relative Value Tween with Repeating

Demonstrates how to use relative string values like '-=64' to animate a property based on its current position, combined with yoyo and repeat settings.

Relative Value Tween with Repeating, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    constructor()
    {
        super();
    }

    preload()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
        this.load.image('block', 'assets/sprites/block.png');
    }

    create()
    {
        var image = this.add.image(400, 500, 'block');

        var tween = this.tweens.add({
            targets: image,
            y: '-=64',
            ease: 'Sine.easeInOut',
            yoyo: true,
            repeat: 6
        });

        console.log(tween);

    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#2d2d2d',
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Tweens58 examples