phaser/Tests/tweens/bounce.ts

37 lines
685 B
TypeScript
Raw Normal View History

2013-07-13 12:38:59 +01:00
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
2013-07-13 12:38:59 +01:00
function preload() {
2013-07-13 12:38:59 +01:00
2013-08-02 18:32:26 +01:00
game.load.image('atari', 'assets/sprites/atari130xe.png');
2013-07-13 12:38:59 +01:00
2013-07-13 12:38:59 +01:00
}
var atari: Phaser.Sprite;
function create() {
2013-08-02 18:32:26 +01:00
atari = game.add.sprite(300, 0, 'atari');
2013-07-13 12:38:59 +01:00
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
2013-08-02 18:32:26 +01:00
var bounce: Phaser.Tween = game.add.tween(atari);
2013-07-13 12:38:59 +01:00
bounce.to({ y: 500 }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
bounce.onComplete.add(startBounceTween, this);
bounce.start();
}
})();