mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
32 lines
562 B
JavaScript
32 lines
562 B
JavaScript
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
|
|
|
var phaser;
|
|
|
|
function preload() {
|
|
|
|
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
|
|
|
|
}
|
|
|
|
function create() {
|
|
|
|
game.stage.backgroundColor = '#736357';
|
|
|
|
phaser = game.add.sprite(300, 300, 'phaser');
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
if (game.input.keyboard.justPressed(Phaser.Keyboard.UP))
|
|
{
|
|
phaser.y--;
|
|
}
|
|
|
|
if (game.input.keyboard.justPressed(Phaser.Keyboard.DOWN))
|
|
{
|
|
phaser.y++;
|
|
}
|
|
|
|
}
|