phaser/examples/wip/camera follow.js
photonstorm 30fbbec675 BitmapData.addTo removed and enhanced BitmapData.add so it can accept either a single Sprite/Image or an Array of them.
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.
2014-02-13 14:19:41 +00:00

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() {
}