2013-10-22 02:58:20 +00:00
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update,render : render });
|
|
|
|
|
|
|
|
function preload() {
|
|
|
|
|
|
|
|
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
|
|
|
game.load.image('card', 'assets/sprites/mana_card.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var card;
|
|
|
|
var Keys = Phaser.Keyboard;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-10-23 16:11:06 +00:00
|
|
|
game.world.setBounds(0, 0, 1920, 1200);
|
|
|
|
|
2013-10-22 02:58:20 +00:00
|
|
|
game.add.sprite(0, 0, 'backdrop');
|
|
|
|
|
|
|
|
card = game.add.sprite(200, 200, 'card');
|
|
|
|
|
|
|
|
card.body.velocity.x = 50;
|
|
|
|
card.scale.setTo(2, 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
|
|
|
if (game.input.keyboard.isDown(Keys.LEFT))
|
|
|
|
{
|
|
|
|
card.x -= 4;
|
|
|
|
}
|
|
|
|
else if (game.input.keyboard.isDown(Keys.RIGHT))
|
|
|
|
{
|
|
|
|
card.x += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game.input.keyboard.isDown(Keys.UP))
|
|
|
|
{
|
|
|
|
card.y -= 4;
|
|
|
|
}
|
|
|
|
else if (game.input.keyboard.isDown(Keys.DOWN))
|
|
|
|
{
|
|
|
|
card.y += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
|
|
|
game.debug.renderCameraInfo(game.camera, 32, 32);
|
|
|
|
game.debug.renderSpriteInfo(card, 32, 200);
|
|
|
|
|
|
|
|
}
|