Skip to content

Commit 30fbbec

Browse files
committed
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.
1 parent 9d6d312 commit 30fbbec

7 files changed

Lines changed: 135 additions & 973 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Significant API changes:
8383
* Stage.scaleMode has been moved to StageScaleMode.scaleMode (so now game.scale.scaleMode)
8484
* Stage.fullScreenScaleMode has been moved to StageScaleMode.fullScreenScaleMode (so now game.scale.fullScreenScaleMode)
8585
* Stage.canvas has been moved to Game.canvas (which used to be a reference to Stage.canvas, but is now the actual object).
86+
* BitmapData.addTo removed and enhanced BitmapData.add so it can accept either a single Sprite/Image or an Array of them.
87+
* 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.
8688

8789

8890
New features:

examples/wip/camera follow.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
7+
game.load.image('box', 'assets/sprites/block.png');
8+
9+
}
10+
11+
var cursors;
12+
var sprite;
13+
14+
function create() {
15+
16+
game.world.setBounds(0, 0, 1920, 1200);
17+
game.add.image(0, 0, 'backdrop');
18+
19+
sprite = game.add.sprite(300, 300, 'box');
20+
21+
game.camera.follow(sprite);
22+
23+
cursors = game.input.keyboard.createCursorKeys();
24+
25+
}
26+
27+
function update() {
28+
29+
if (cursors.left.isDown)
30+
{
31+
sprite.x -= 8;
32+
}
33+
else if (cursors.right.isDown)
34+
{
35+
sprite.x += 8;
36+
}
37+
38+
if (cursors.up.isDown)
39+
{
40+
sprite.y -= 8;
41+
}
42+
else if (cursors.down.isDown)
43+
{
44+
sprite.y += 8;
45+
}
46+
47+
}
48+
49+
function render() {
50+
51+
52+
}

examples/wip/camera.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
7+
game.load.image('box', 'assets/sprites/block.png');
8+
9+
}
10+
11+
var cursors;
12+
13+
function create() {
14+
15+
game.world.setBounds(0, 0, 1920, 1200);
16+
game.add.sprite(0, 0, 'backdrop');
17+
18+
cursors = game.input.keyboard.createCursorKeys();
19+
20+
}
21+
22+
function update() {
23+
24+
if (cursors.left.isDown)
25+
{
26+
game.camera.x -= 8;
27+
}
28+
else if (cursors.right.isDown)
29+
{
30+
game.camera.x += 8;
31+
}
32+
33+
if (cursors.up.isDown)
34+
{
35+
game.camera.y -= 8;
36+
}
37+
else if (cursors.down.isDown)
38+
{
39+
game.camera.y += 8;
40+
}
41+
42+
}
43+
44+
function render() {
45+
46+
47+
}

examples/wip/p28.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function px2p(v) {
2222

2323
function create() {
2424

25-
// game.world.setBounds(0, 0, 1920, 1200);
25+
game.world.setBounds(0, 0, 1920, 1200);
2626
game.add.sprite(0, 0, 'backdrop');
2727

2828
game.physics.onBodyAdded.add(addedToWorld, this);

src/core/Stage.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@ Phaser.Stage = function (game, width, height) {
2323
this.game = game;
2424

2525
/**
26-
* @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property.
27-
* @private
28-
*/
29-
this._backgroundColor = 'rgb(0,0,0)';
30-
31-
/**
32-
* @property {Phaser.Point} offset - Get the offset values (for input and other things).
26+
* @property {Phaser.Point} offset - Holds the offset coordinates of the Game.canvas from the top-left of the browser window (used by Input and other classes)
3327
*/
3428
this.offset = new Phaser.Point();
3529

3630
PIXI.Stage.call(this, 0x000000, false);
3731

32+
/**
33+
* @property {string} name - The name of this object.
34+
* @default
35+
*/
3836
this.name = '_stage_root';
37+
3938
this.interactive = false;
4039

4140
/**
@@ -44,18 +43,18 @@ Phaser.Stage = function (game, width, height) {
4443
*/
4544
this.disableVisibilityChange = false;
4645

47-
/**
48-
* @property {number} _nextOffsetCheck - The time to run the next offset check.
49-
* @private
50-
*/
51-
this._nextOffsetCheck = 0;
52-
5346
/**
5447
* @property {number|false} checkOffsetInterval - The time (in ms) between which the stage should check to see if it has moved.
5548
* @default
5649
*/
5750
this.checkOffsetInterval = 2500;
5851

52+
/**
53+
* @property {number} _nextOffsetCheck - The time to run the next offset check.
54+
* @private
55+
*/
56+
this._nextOffsetCheck = 0;
57+
5958
if (game.config)
6059
{
6160
this.parseConfig(game.config);

0 commit comments

Comments
 (0)