2013-10-22 02:58:20 +00:00
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
|
|
|
|
2013-12-17 16:48:03 +00:00
|
|
|
var tilesprite;
|
|
|
|
var cursors;
|
2013-10-22 02:58:20 +00:00
|
|
|
|
|
|
|
function preload() {
|
2013-12-17 16:48:03 +00:00
|
|
|
|
2013-10-22 02:58:20 +00:00
|
|
|
game.load.image('starfield', 'assets/misc/starfield.jpg');
|
2013-12-17 16:48:03 +00:00
|
|
|
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function create() {
|
2013-12-17 16:48:03 +00:00
|
|
|
|
|
|
|
tilesprite = game.add.tileSprite(0, 0, 800, 600, 'starfield');
|
|
|
|
|
|
|
|
cursors = game.input.keyboard.createCursorKeys();
|
|
|
|
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
2013-12-17 16:48:03 +00:00
|
|
|
if (cursors.left.isDown)
|
2013-10-22 02:58:20 +00:00
|
|
|
{
|
2013-12-17 16:48:03 +00:00
|
|
|
tilesprite.tilePosition.x += 8;
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
2013-12-17 16:48:03 +00:00
|
|
|
else if (cursors.right.isDown)
|
2013-10-22 02:58:20 +00:00
|
|
|
{
|
2013-12-17 16:48:03 +00:00
|
|
|
tilesprite.tilePosition.x -= 8;
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 16:48:03 +00:00
|
|
|
if (cursors.up.isDown)
|
2013-10-22 02:58:20 +00:00
|
|
|
{
|
2013-12-17 16:48:03 +00:00
|
|
|
tilesprite.tilePosition.y += 8;
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
2013-12-17 16:48:03 +00:00
|
|
|
else if (cursors.down.isDown)
|
2013-10-22 02:58:20 +00:00
|
|
|
{
|
2013-12-17 16:48:03 +00:00
|
|
|
tilesprite.tilePosition.y -= 8;
|
2013-10-22 02:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|