Skip to content

Commit e861073

Browse files
committed
Merge branch 'master' into rendering-cleanup
2 parents a4e7987 + 81609c4 commit e861073

15 files changed

Lines changed: 409 additions & 50 deletions

File tree

.eslintrc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"indent": [ "error", 4, { "SwitchCase": 1 } ],
4747
"key-spacing": [ "error", { "beforeColon": false, "afterColon": true }],
4848
"linebreak-style": [ "off" ],
49-
"lines-around-comment": [ "error", { "beforeBlockComment": true, "afterBlockComment": false, "beforeLineComment": true, "afterLineComment": false, "allowBlockStart": true, "allowBlockEnd": false, "allowObjectStart": true, "allowArrayStart": true, "allowBlockEnd": true }],
49+
"lines-around-comment": [ "error", { "beforeBlockComment": true, "afterBlockComment": false, "beforeLineComment": true, "afterLineComment": false, "allowBlockStart": true, "allowBlockEnd": false, "allowObjectStart": true, "allowArrayStart": true }],
5050
"new-parens": "error",
5151
"no-array-constructor": "error",
5252
"no-lonely-if": "error",
@@ -66,7 +66,7 @@
6666
"space-in-parens": [ "error", "never" ],
6767
"space-infix-ops": [ "error", { "int32Hint": true } ],
6868
"wrap-regex": "error",
69-
"spaced-comment": [ "error", "always", { "block": { "balanced": true }} ]
69+
"spaced-comment": [ "error", "always", { "block": { "balanced": true, "exceptions": ["*", "!"] }} ]
7070

7171
}
72-
}
72+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"//": "npm publish --tag beta",
33
"name": "phaser",
4-
"version": "3.0.0-beta.18",
4+
"version": "3.0.0-beta.19",
55
"release": "Shadow Coast",
66
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
77
"author": "Richard Davey <rdavey@gmail.com> (http://www.photonstorm.com)",

src/gameobjects/text/static/Text.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ var Text = new Class({
576576
w *= this.resolution;
577577
h *= this.resolution;
578578

579+
w = Math.max(w, 1);
580+
h = Math.max(h, 1);
581+
579582
if (canvas.width !== w || canvas.height !== h)
580583
{
581584
canvas.width = w;

src/gameobjects/tilemap/Tile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ var Tile = new Class({
182182
* @default
183183
*/
184184
this.tint = 0xffffff;
185+
186+
/**
187+
* An empty object where physics-engine specific information (e.g. bodies) may be stored.
188+
* @property {object} physics
189+
*/
190+
this.physics = {};
185191
},
186192

187193
/**

src/input/InputManager.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
// Phaser.Input.InputManager
2-
31
var Class = require('../utils/Class');
42
var EventEmitter = require('eventemitter3');
53
var Gamepad = require('./gamepad/GamepadManager');
64
var Keyboard = require('./keyboard/KeyboardManager');
75
var Mouse = require('./mouse/MouseManager');
86
var Pointer = require('./Pointer');
7+
var Rectangle = require('../geom/rectangle/Rectangle');
98
var Touch = require('./touch/TouchManager');
109
var TransformXY = require('../math/TransformXY');
1110

11+
// Phaser.Input.InputManager
12+
1213
var InputManager = new Class({
1314

1415
initialize:
@@ -46,7 +47,7 @@ var InputManager = new Class({
4647

4748
this.ignoreEvents = false;
4849

49-
this.bounds;
50+
this.bounds = new Rectangle();
5051

5152
this._tempPoint = { x: 0, y: 0 };
5253
this._tempHitTest = [];
@@ -72,22 +73,16 @@ var InputManager = new Class({
7273

7374
updateBounds: function ()
7475
{
75-
var bounds = this.canvas.getBoundingClientRect();
76-
77-
if (window.scrollX)
78-
{
79-
bounds.left += window.scrollX;
80-
}
81-
82-
if (window.scrollY)
83-
{
84-
bounds.top += window.scrollY;
85-
}
76+
var clientRect = this.canvas.getBoundingClientRect();
77+
var bounds = this.bounds;
8678

87-
this.bounds = bounds;
79+
bounds.left = clientRect.left + window.pageXOffset;
80+
bounds.top = clientRect.top + window.pageYOffset;
81+
bounds.width = clientRect.width;
82+
bounds.height = clientRect.height;
8883
},
8984

90-
update: function (time, delta)
85+
update: function (time)
9186
{
9287
this.keyboard.update();
9388
this.gamepad.update();

src/loader/filetypes/HTML5AudioFile.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var HTML5AudioFile = new Class({
1515
{
1616
this.locked = locked;
1717

18+
this.loaded = false;
19+
1820
var fileConfig = {
1921
type: 'audio',
2022
extension: GetFastValue(url, 'type', ''),
@@ -29,7 +31,14 @@ var HTML5AudioFile = new Class({
2931

3032
onLoad: function ()
3133
{
32-
this.callback(this, true);
34+
if(this.loaded)
35+
{
36+
return;
37+
}
38+
39+
this.loaded = true;
40+
41+
this.loader.nextFile(this, true);
3342
},
3443

3544
onError: function (event)
@@ -41,7 +50,7 @@ var HTML5AudioFile = new Class({
4150
audio.onerror = null;
4251
}
4352

44-
this.callback(this, false);
53+
this.loader.nextFile(this, false);
4554
},
4655

4756
onProgress: function (event)
@@ -50,18 +59,22 @@ var HTML5AudioFile = new Class({
5059
audio.oncanplaythrough = null;
5160
audio.onerror = null;
5261

53-
if(++this.filesLoaded === this.filesTotal)
62+
this.filesLoaded++;
63+
64+
this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1);
65+
66+
this.loader.emit('fileprogress', this, this.percentComplete);
67+
68+
if(this.filesLoaded === this.filesTotal)
5469
{
5570
this.onLoad();
5671
}
57-
58-
this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1);
5972
},
6073

6174
// Called by the Loader, starts the actual file downloading
62-
load: function (callback, baseURL)
75+
load: function (loader)
6376
{
64-
this.callback = callback;
77+
this.loader = loader;
6578

6679
this.data = [];
6780

@@ -90,7 +103,7 @@ var HTML5AudioFile = new Class({
90103
for (i = 0; i < this.data.length; i++)
91104
{
92105
audio = this.data[i];
93-
audio.src = GetURL(this, baseURL || '');
106+
audio.src = GetURL(this, loader.baseURL);
94107

95108
if (!this.locked)
96109
{
@@ -100,13 +113,7 @@ var HTML5AudioFile = new Class({
100113

101114
if (this.locked)
102115
{
103-
setTimeout(function ()
104-
{
105-
this.filesLoaded = this.filesTotal;
106-
this.percentComplete = 1;
107-
this.onLoad();
108-
109-
}.bind(this));
116+
setTimeout(this.onLoad.bind(this));
110117
}
111118
}
112119

src/loader/filetypes/TilemapJSONFile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ var TilemapJSONFile = function (key, url, path, format, xhrSettings)
1717
};
1818

1919
// When registering a factory function 'this' refers to the Loader context.
20-
//
20+
//
2121
// There are several properties available to use:
22-
//
22+
//
2323
// this.scene - a reference to the Scene that owns the GameObjectFactory
2424

2525
FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings)
@@ -48,12 +48,12 @@ FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings)
4848
for (var i = 0; i < key.length; i++)
4949
{
5050
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
51-
this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER.TILED_JSON, xhrSettings));
51+
this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
5252
}
5353
}
5454
else
5555
{
56-
this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER.TILED_JSON, xhrSettings));
56+
this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
5757
}
5858

5959
// For method chaining

src/physics/matter-js/Factory.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ var Constraint = require('./lib/constraint/Constraint');
55
var MatterImage = require('./MatterImage');
66
var MatterSprite = require('./MatterSprite');
77
var PointerConstraint = require('./PointerConstraint');
8+
var MatterTileBody = require('./MatterTileBody');
89

910
// When registering a factory function 'this' refers to the GameObjectFactory context.
10-
//
11+
//
1112
// There are several properties available to use:
12-
//
13+
//
1314
// this.scene - a reference to the Scene that owns the GameObjectFactory
1415
// this.displayList - a reference to the Display List the Scene owns
1516
// this.updateList - a reference to the Update List the Scene owns
@@ -219,6 +220,13 @@ var Factory = new Class({
219220
return image;
220221
},
221222

223+
tileBody: function (tile, options)
224+
{
225+
var tileBody = new MatterTileBody(this.world, tile, options);
226+
227+
return tileBody;
228+
},
229+
222230
sprite: function (x, y, key, frame, options)
223231
{
224232
var sprite = new MatterSprite(this.world, x, y, key, frame, options);

0 commit comments

Comments
 (0)