mirror of
https://github.com/photonstorm/phaser
synced 2024-12-04 18:40:59 +00:00
30fbbec675
BitmapData has had all of the EaselJS functions removed. It was just taking up space and you can do it all via BitmapData.context directly. Camera following now working again.
52 lines
858 B
JavaScript
52 lines
858 B
JavaScript
|
|
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('box', 'assets/sprites/block.png');
|
|
|
|
}
|
|
|
|
var cursors;
|
|
var sprite;
|
|
|
|
function create() {
|
|
|
|
game.world.setBounds(0, 0, 1920, 1200);
|
|
game.add.image(0, 0, 'backdrop');
|
|
|
|
sprite = game.add.sprite(300, 300, 'box');
|
|
|
|
game.camera.follow(sprite);
|
|
|
|
cursors = game.input.keyboard.createCursorKeys();
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
if (cursors.left.isDown)
|
|
{
|
|
sprite.x -= 8;
|
|
}
|
|
else if (cursors.right.isDown)
|
|
{
|
|
sprite.x += 8;
|
|
}
|
|
|
|
if (cursors.up.isDown)
|
|
{
|
|
sprite.y -= 8;
|
|
}
|
|
else if (cursors.down.isDown)
|
|
{
|
|
sprite.y += 8;
|
|
}
|
|
|
|
}
|
|
|
|
function render() {
|
|
|
|
|
|
}
|