Phaser 2.0.4 test environment
Basic Phaser setup for testing
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/phaser/2.0.4/phaser.min.js"></script>
<div id="test"></div>
JavaScript
// Phaser 2.0.4 test environment
// Removing tweens - click inside the canvas then press space to stop the tween
var game = new Phaser.Game(500, 400, Phaser.AUTO, 'test');
var BasicGame = function(game) {};
BasicGame.Boot = function (game) {
//game.time.advancedTiming = true;
idleBallTween = null;
};
BasicGame.Boot.prototype =
{
create: function()
{
var ball = game.add.graphics();
ball.beginFill(0xffffff);
ball.drawCircle(20, 20, 20);
idleBallTween = this.game.add.tween(ball).to({y: 50}, 500 , Phaser.Easing.Sinusoidal.InOut, true, 0, 9999, true);
},
update: function()
{
if (this.game.input.keyboard.justPressed(Phaser.Keyboard.SPACEBAR)) {
game.tweens.remove(idleBallTween);
}
},
render: function()
{
game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");
game.debug.text("Tween running: " + !idleBallTween.pendingDelete, 2, 110);
}
}
game.state.add('Boot', BasicGame.Boot);
game.state.start('Boot');