Skip to content

Commit 6cde583

Browse files
committed
Merge branch 'dev' of https://github.com/photonstorm/phaser into dev
2 parents ab02040 + 32f5a2f commit 6cde583

9 files changed

Lines changed: 536 additions & 771 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Updates:
148148
* Removed the console.log redirect from Utils as it was messing with Firefox.
149149
* Body.acceleration is now much smoother and less eratic at high speeds.
150150
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
151+
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
151152

152153

153154
Bug Fixes:

build/phaser.js

Lines changed: 437 additions & 707 deletions
Large diffs are not rendered by default.

build/phaser.min.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/_site/examples.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@
126126
"file": "offset+bounding+box.js",
127127
"title": "offset bounding box"
128128
},
129+
{
130+
"file": "process+callback.js",
131+
"title": "process callback"
132+
},
129133
{
130134
"file": "sprite+tiles.js",
131135
"title": "sprite tiles"
@@ -134,10 +138,6 @@
134138
"file": "sprite+vs+group.js",
135139
"title": "sprite vs group"
136140
},
137-
{
138-
"file": "sprite+vs+sprite+custom.js",
139-
"title": "sprite vs sprite custom"
140-
},
141141
{
142142
"file": "sprite+vs+sprite.js",
143143
"title": "sprite vs sprite"
@@ -620,6 +620,10 @@
620620
"file": "framerate+independence.js",
621621
"title": "framerate independence"
622622
},
623+
{
624+
"file": "gravity.js",
625+
"title": "gravity"
626+
},
623627
{
624628
"file": "launcher+follow+world.js",
625629
"title": "launcher follow world"
@@ -796,6 +800,10 @@
796800
"file": "sci+fly.js",
797801
"title": "sci fly"
798802
},
803+
{
804+
"file": "shuffle+tiles.js",
805+
"title": "shuffle tiles"
806+
},
799807
{
800808
"file": "swap+tiles.js",
801809
"title": "swap tiles"

examples/collision/group vs group.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function update() {
6868
fireBullet();
6969
}
7070

71-
game.physics.collide(bullets, veggies, collisionHandler, null, this);
71+
// As we don't need to exchange any velocities or motion we can use the faster 'overlap' check instead of 'collide':
72+
game.physics.overlap(bullets, veggies, collisionHandler, null, this);
7273

7374
}
7475

examples/games/starstruck.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
44
function preload() {
55

66
game.load.tilemap('level1', 'assets/games/starstruck/level1.json', null, Phaser.Tilemap.TILED_JSON);
7-
game.load.tileset('tiles', 'assets/games/starstruck/tiles-1.png', 16, 16);
7+
game.load.image('tiles-1', 'assets/games/starstruck/tiles-1.png');
88
game.load.spritesheet('dude', 'assets/games/starstruck/dude.png', 32, 48);
99
game.load.spritesheet('droid', 'assets/games/starstruck/droid.png', 32, 32);
1010
game.load.image('starSmall', 'assets/games/starstruck/star.png');
@@ -32,20 +32,22 @@ function create() {
3232

3333
map = game.add.tilemap('level1');
3434

35-
tileset = game.add.tileset('tiles');
35+
map.addTilesetImage('tiles-1');
3636

37-
tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true);
37+
map.setCollisionByExclusion([ 13, 14, 15, 16, 46, 47, 48, 49, 50, 51 ]);
3838

39-
tileset.setCollisionRange(12, 16, false, false, false, false);
40-
tileset.setCollisionRange(46, 50, false, false, false, false);
39+
layer = map.createLayer('Tile Layer 1');
40+
41+
// Un-comment this on to see the collision tiles
42+
// layer.debug = true;
4143

42-
layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0);
4344
layer.resizeWorld();
4445

46+
game.physics.gravity.y = 260;
47+
4548
player = game.add.sprite(32, 32, 'dude');
4649
player.body.bounce.y = 0.2;
4750
player.body.collideWorldBounds = true;
48-
player.body.gravity.y = 6;
4951
player.body.setSize(16, 32, 8, 16);
5052

5153
player.animations.add('left', [0, 1, 2, 3], 10, true);
@@ -110,13 +112,10 @@ function update() {
110112
jumpTimer = game.time.now + 750;
111113
}
112114

113-
// player.scale.x += 0.001;
114-
// player.scale.y += 0.001;
115-
116115
}
117116

118117
function render () {
119118

120-
game.debug.renderSpriteBody(player);
119+
// game.debug.renderSpriteBody(player);
121120

122121
}

examples/physics/gravity.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
3+
4+
function preload() {
5+
6+
game.load.image('ilkke', 'assets/sprites/ilkke.png');
7+
8+
}
9+
10+
var sprite1;
11+
var sprite2;
12+
var sprite3;
13+
14+
function create() {
15+
16+
game.stage.backgroundColor = '#2d2d2d';
17+
18+
// Set the world (global) gravity
19+
game.physics.gravity.y = 100;
20+
21+
// Sprite 1 will use the World (global) gravity
22+
sprite1 = game.add.sprite(300, 32, 'ilkke');
23+
sprite1.body.collideWorldBounds = true;
24+
sprite1.body.bounce.y = 0.8;
25+
26+
// Sprite 2 is set to ignore the global gravity and use its own value
27+
sprite2 = game.add.sprite(400, 32, 'ilkke');
28+
sprite2.body.collideWorldBounds = true;
29+
sprite2.body.bounce.y = 0.8;
30+
sprite2.body.allowGravity = false;
31+
sprite2.body.gravity.y = 100;
32+
33+
// Sprite 3 will use both the global gravity and its own value
34+
sprite3 = game.add.sprite(500, 32, 'ilkke');
35+
sprite3.body.collideWorldBounds = true;
36+
sprite3.body.bounce.y = 0.8;
37+
sprite3.body.gravity.y = 100;
38+
39+
}

src/core/Game.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ Phaser.Game.prototype = {
581581
else
582582
{
583583
this.plugins.preUpdate();
584-
this.physics.preUpdate();
585584
this.world.preUpdate();
586585

587586
this.stage.update();

src/physics/arcade/ArcadePhysics.js

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ Phaser.Physics.Arcade = function (game) {
3434
*/
3535
this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height);
3636

37-
/**
38-
* @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad.
39-
*/
40-
this.maxObjects = 10;
41-
42-
/**
43-
* @property {number} maxLevels - Used by the QuadTree to set the maximum number of iteration levels.
44-
*/
45-
this.maxLevels = 4;
46-
4737
/**
4838
* @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks.
4939
*/
@@ -52,12 +42,17 @@ Phaser.Physics.Arcade = function (game) {
5242
/**
5343
* @property {Phaser.QuadTree} quadTree - The world QuadTree.
5444
*/
55-
this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
45+
this.quadTree = new Phaser.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
46+
47+
/**
48+
* @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad.
49+
*/
50+
this.maxObjects = 10;
5651

5752
/**
58-
* @property {number} quadTreeID - The QuadTree ID.
53+
* @property {number} maxLevels - Used by the QuadTree to set the maximum number of iteration levels.
5954
*/
60-
this.quadTreeID = 0;
55+
this.maxLevels = 4;
6156

6257
// Avoid gc spikes by caching these values for re-use
6358

@@ -157,6 +152,17 @@ Phaser.Physics.Arcade = function (game) {
157152
*/
158153
this._dy = 0;
159154

155+
/**
156+
* @property {number} _gravityX - Internal cache var.
157+
* @private
158+
*/
159+
this._gravityX = 0;
160+
161+
/**
162+
* @property {number} _gravityY - Internal cache var.
163+
* @private
164+
*/
165+
this._gravityY = 0;
160166
};
161167

162168
Phaser.Physics.Arcade.prototype = {
@@ -173,13 +179,13 @@ Phaser.Physics.Arcade.prototype = {
173179

174180
if (body.allowGravity)
175181
{
176-
this._gravityX = (this.gravity.x + body.gravity.x);
177-
this._gravityY = (this.gravity.y + body.gravity.y);
182+
this._gravityX = this.gravity.x + body.gravity.x;
183+
this._gravityY = this.gravity.y + body.gravity.y;
178184
}
179185
else
180186
{
181-
this._gravityX = 0;
182-
this._gravityY = 0;
187+
this._gravityX = body.gravity.x;
188+
this._gravityY = body.gravity.y;
183189
}
184190

185191
// Rotation
@@ -223,24 +229,6 @@ Phaser.Physics.Arcade.prototype = {
223229

224230
},
225231

226-
/**
227-
* Called automatically by the core game loop.
228-
*
229-
* @method Phaser.Physics.Arcade#preUpdate
230-
* @protected
231-
*/
232-
preUpdate: function () {
233-
},
234-
235-
/**
236-
* Called automatically by the core game loop.
237-
*
238-
* @method Phaser.Physics.Arcade#postUpdate
239-
* @protected
240-
*/
241-
postUpdate: function () {
242-
},
243-
244232
/**
245233
* Checks for overlaps between two game objects. The objects can be Sprites, Groups or Emitters.
246234
* You can perform Sprite vs. Sprite, Sprite vs. Group and Group vs. Group overlap checks.

0 commit comments

Comments
 (0)