mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
24 lines
822 B
JavaScript
24 lines
822 B
JavaScript
/// <reference path="../../Phaser/Game.ts" />
|
|
(function () {
|
|
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update);
|
|
var box;
|
|
function create() {
|
|
box = myGame.add.geomSprite(0, 0);
|
|
box.createRectangle(64, 64);
|
|
box.renderOutline = false;
|
|
}
|
|
function update() {
|
|
box.velocity.x = 0;
|
|
box.velocity.y = 0;
|
|
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
|
box.velocity.x = -200;
|
|
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
|
box.velocity.x = 200;
|
|
}
|
|
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
|
box.velocity.y = -200;
|
|
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
|
box.velocity.y = 200;
|
|
}
|
|
}
|
|
})();
|