Skip to content

Instantly share code, notes, and snippets.

@corpsefilth
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corpsefilth/19b652d5837ebb1771fe to your computer and use it in GitHub Desktop.
Save corpsefilth/19b652d5837ebb1771fe to your computer and use it in GitHub Desktop.
Tween information. Phaser
// Create a tween on the label
var tween = game.add.tween(nameLabel);
// Change the y position of the label to 80, in 1000 ms
tween.to({y: 80}, 1000);
// Start the tween
tween.start();
game.add.tween(nameLabel).to({y: 80}, 1000).start();
game.add.tween(nameLabel).to({y: 80}, 1000).easing(Phaser.Easing.Bounce.Out).start();
// Create the tween
var tween = game.add.tween(startLabel);
// Rotate the label to -2 degrees in 500ms
tween.to({angle: -2}, 500);
// Then rotate the label to +2 degrees in 500ms
tween.to({angle: 2}, 500);
// Loop indefinitely the tween
tween.loop();
// Start the tween
tween.start();
// all together
game.add.tween(startLabel).to({angle: -2}, 500).to({angle: 2}, 500).loop().start();
//More tween samples
// Add a 100ms delay before the tween starts
tween.delay(100);
// Repeat the tween 5 times
tween.repeat(5);
// Stop the tween
tween.stop();
// Return true if the tween is currently playing
tween.isRunning;
// Will call 'callback' once the tween is finished
tween.onComplete.add(callback, this);
// And there are lots of other easing functions you can try, like:
tween.easing(Phaser.Easing.Sinusoidal.In);
tween.easing(Phaser.Easing.Exponential.Out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment