Multiple Properties with Individual Yoyo
Demonstrates how to apply independent durations, easing functions, and yoyo effects to multiple properties within a single tween.
800 × 600
var config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'game-container',
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('block', 'assets/sprites/block.png');
}
function create ()
{
var image = this.add.image(100, 100, 'block');
this.tweens.add({
targets: image,
x: { value: 700, duration: 4000, ease: 'Power2', yoyo: -1 },
y: { value: 400, duration: 1500, ease: 'Bounce.easeOut', yoyo: -1 }
});
}