mirror of
https://github.com/wassname/phaser.git
synced 2026-08-12 12:20:38 +08:00
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.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
|
||||
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() {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
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;
|
||||
|
||||
function create() {
|
||||
|
||||
game.world.setBounds(0, 0, 1920, 1200);
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
game.camera.x -= 8;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
game.camera.x += 8;
|
||||
}
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
game.camera.y -= 8;
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
game.camera.y += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ function px2p(v) {
|
||||
|
||||
function create() {
|
||||
|
||||
// game.world.setBounds(0, 0, 1920, 1200);
|
||||
game.world.setBounds(0, 0, 1920, 1200);
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
game.physics.onBodyAdded.add(addedToWorld, this);
|
||||
|
||||
Reference in New Issue
Block a user