class Example extends Phaser.Scene {
preload() {
this.load.image("duck", "https://assets.codepen.io/9367036/duck.png");
}
create() {
const img = this.add.image(100, 200, "duck");
this.tweens.chain({
targets: img,
loop: -1, // infini
tweens: [
{
x: 400,
angle: -90,
ease: "Expo.easeOut",
duration: 1500
},
{
y: 100,
ease: "Sine.easeIn",
duration: 1500
},
{
y: 300,
ease: "Sine.easeInOut",
duration: 500
},
{
x: 700,
y: 200,
angle: 0,
ease: "Expo.easeIn",
duration: 1000
},
{
y: 200,
ease: "Sine.easeOut",
duration: 1000
},
{
x: 100,
y: 200,
angle: 360,
duration: 1000,
onComplete: () => {
// On peut réinitialiser certains paramètres au besoin. Ca dépends vraiment des animations
// ex: img.angle = 0;
}
}
]
});
}
}
const config = {
type: Phaser.AUTO,
transparent: true,
width: 800,
height: 400,
scene: Example
};
const game = new Phaser.Game(config);