8000 Merge branch 'dev' into multitexture-gl · ITCSsDeveloper/phaser@1755bfd · GitHub
Skip to content

Commit 1755bfd

Browse files
committed
Merge branch 'dev' into multitexture-gl
2 parents 44774d6 + f669202 commit 1755bfd

16 files changed

Lines changed: 813 additions & 614 deletions

File tree

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,22 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
316316

317317
### Updates
318318

319-
* TypeScript definitions fixes and updates (thanks )
320-
* Docs typo fixes (thanks @rroylance @Owumaro)
319+
* TypeScript definitions fixes and updates (thanks @calvindavis)
320+
* Docs typo fixes (thanks @rroylance @Owumaro @boniatillo-com)
321321
* The InputHandler.flagged property has been removed. It was never used internally, or exposed via the API, so was just overhead.
322322
* The src/system folder has been removed and all files relocated to the src/utils folder. This doesn't change anything from an API point of view, but did change the grunt build scripts slightly.
323323
* BitmapData.shadow and BitmapData.text now both `return this` keeping them in-line with the docs (thanks @greeny #2634)
324+
* Group.align has had its arguments changed so that it's now `(width, height, ...)` instead of `(rows, columns, ...)` (thanks @deargle #2643)
325+
* Group.align now returns `true` if the Group was aligned, or `false` if not.
326+
* The Loader.headers object has a new property `requestedWith`. By default this is set to `false`, but it can be used to set the `X-Requested-With` header to `XMLHttpRequest` (or any other value you need). To enable this do `this.load.headers.requestedWith = 'XMLHttpRequest'` before adding anything to the Loader.
327+
* ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
328+
* Phaser.Tileset has a new property `lastgid` which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset.
324329

325330
### Bug Fixes
326331

327332
* A Group with `inputEnableChildren` set would re-start the Input Handler on a Sprite, even if that handler had been disabled previously.
328-
*
329-
*
333+
* Weapon.autofire wouldn't fire after the first bullet, or until `fire` was called, neither of which are requirements. If you now set this boolean the Weapon will fire continuously until you toggle it back to false (thanks @alverLopez #2647)
334+
* ArcadePhysics.World.angleBetweenCenters now uses `centerX` and `centerY` properties to check for the angle between, instead of `center.x/y` as that property no longer exists (thanks @leopoldobrines7 #2654)
330335

331336
### Pixi Updates
332337

src/Phaser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var Phaser = Phaser || {
1515
* @constant
1616
* @type {string}
1717
*/
18-
VERSION: '2.7.0 Beta',
18+
VERSION: '2.7.0 Beta 2',
1919

2020
/* 10BC8 *
2121
* An array of Phaser game instances.

src/core/Group.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ Phaser.Group.prototype.updateZ = function () {
685685
* the `alignTo` method in order to be positioned by this call. All default Phaser Game Objects have
686686
* this.
687687
*
688-
* The grid dimensions are determined by the first four arguments. The `rows` and `columns` arguments
688+
* The grid dimensions are determined by the first four arguments. The `width` and `height` arguments
689689
* relate to the width and height of the grid respectively.
690690
*
691691
* For example if the Group had 100 children in it:
@@ -699,13 +699,13 @@ Phaser.Group.prototype.updateZ = function () {
699699
*
700700
* This will align the children into a grid of 25x4, again using 32 pixels per grid cell.
701701
*
702-
* You can choose to set _either_ the `rows` or `columns` value to -1. Doing so tells the method
702+
* You can choose to set _either_ the `width` or `height` value to -1. Doing so tells the method
703703
* to keep on aligning children until there are no children left. For example if this Group had
704704
* 48 children in it, the following:
705705
*
706706
* `Group.align(-1, 8, 32, 32)`
707707
*
708-
* ... will align the children so that there are 8 columns vertically (the second argument),
708+
* ... will align the children so that there are 8 children vertically (the second argument),
709709
* and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48)
710710
*
711711
* You can also do:
@@ -723,26 +723,27 @@ Phaser.Group.prototype.updateZ = function () {
723723
* The final argument; `offset` lets you start the alignment from a specific child index.
724724
*
725725
* @method Phaser.Group#align
726-
* @param {integer} rows - The number of rows, or width, of the grid. Set to -1 for a dynamic width.
727-
* @param {integer} columns - The number of columns, or height, of the grid. Set to -1 for a dynamic height.
726+
* @param {integer} width - The width of the grid in items (not pixels). Set to -1 for a dynamic width. If -1 then you must set an explicit height value.
727+
* @param {integer} height - The height of the grid in items (not pixels). Set to -1 for a dynamic height. If -1 then you must set an explicit width value.
728728
* @param {integer} cellWidth - The width of each grid cell, in pixels.
729729
* @param {integer} cellHeight - The height of each grid cell, in pixels.
730730
* @param {integer} [position] - The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`.
731731
* @param {integer} [offset=0] - Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value.
732+
* @return {boolean} True if the Group children were aligned, otherwise false.
732733
*/
733-
Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, position, offset) {
734+
Phaser.Group.prototype.align = function (width, height, cellWidth, cellHeight, position, offset) {
734735

735736
if (position === undefined) { position = Phaser.TOP_LEFT; }
736737
if (offset === undefined) { offset = 0; }
737738

738-
if (this.children.length === 0 || offset > this.children.length || (rows === -1 && columns === -1))
739+
if (this.children.length === 0 || offset > this.children.length || (width === -1 && height === -1))
739740
{
740-
return;
741+
return false;
741742
}
742743

743744
var r = new Phaser.Rectangle(0, 0, cellWidth, cellHeight);
744-
var w = (rows * cellWidth);
745-
var h = (columns * cellHeight);
745+
var w = (width * cellWidth);
746+
var h = (height * cellHeight);
746747

747748
for (var i = offset; i < this.children.length; i++)
748749
{
@@ -757,7 +758,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
757758
continue;
758759
}
759760

760-
if (rows === -1)
761+
if (width === -1)
761762
{
762763
// We keep laying them out horizontally until we've done them all
763764
r.y += cellHeight;
@@ -768,7 +769,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
768769
r.y = 0;
769770
}
770771
}
771-
else if (columns === -1)
772+
else if (height === -1)
772773
{
773774
// We keep laying them out vertically until we've done them all
774775
r.x += cellWidth;
@@ -792,12 +793,14 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
792793
if (r.y === h)
793794
{
794795
// We've hit the column limit, so return, even if there are children left
795-
return;
796+
return true;
796797
}
797798
}
798799
}
799800
}
800801

802+
return true;
803+
801804
};
802805

803806
/**

src/core/ScaleManager.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ Phaser.ScaleManager = function (game, width, height) {
220220
*/
221221
this.leaveIncorrectOrientation = new Phaser.Signal();
222222

223+
/**
224+
* This boolean provides you with a way to determine if the browser is in Full Screen
225+
* mode (via the Full Screen API), and Phaser was the one responsible for activating it.
226+
*
227+
* It's possible that ScaleManager.isFullScreen returns `true` even if Phaser wasn't the
228+
* one that made the browser go full-screen, so this flag lets you determine that.
229+
*
230+
* @property {boolean} hasPhaserSetFullScreen
231+
* @default
232+
*/
233+
this.hasPhaserSetFullScreen = false;
234+
223235
/**
224236
* If specified, this is the DOM element on which the Fullscreen API enter request will be invoked.
225237
* The target element must have the correct CSS styling and contain the Display canvas.
@@ -1760,9 +1772,11 @@ Phaser.ScaleManager.prototype = {
17601772
{
17611773
// Error is called in timeout to emulate the real fullscreenerror event better
17621774
var _this = this;
1775+
17631776
setTimeout(function () {
17641777
_this.fullScreenError();
17651778
}, 10);
1779+
17661780
return;
17671781
}
17681782

@@ -1779,7 +1793,7 @@ Phaser.ScaleManager.prototype = {
17791793
}
17801794
}
17811795

1782-
if (typeof antialias !== 'undefined' && this.game.renderType === Phaser.CANVAS)
1796+
if (antialias !== undefined && this.game.renderType === Phaser.CANVAS)
17831797
{
17841798
this.game.stage.smoothed = antialias;
17851799
}
@@ -1798,6 +1812,8 @@ Phaser.ScaleManager.prototype = {
17981812
targetElement: fsTarget
17991813
};
18001814

1815+
this.hasPhaserSetFullScreen = true;
1816+
18011817
this.onFullScreenInit.dispatch(this, initData);
18021818

18031819
if (this._createdFullScreenTarget)
@@ -1837,6 +1853,8 @@ Phaser.ScaleManager.prototype = {
18371853
return false;
18381854
}
18391855

1856+
this.hasPhaserSetFullScreen = false;
1857+
18401858
document[this.game.device.cancelFullscreen]();
18411859

18421860
return true;
@@ -2083,14 +2101,17 @@ Phaser.ScaleManager.prototype.constructor = Phaser.ScaleManager;
20832101
Object.defineProperty(Phaser.ScaleManager.prototype, "boundingParent", {
20842102

20852103
get: function () {
2104+
20862105
if (this.parentIsWindow ||
2087-
(this.isFullScreen && !this._createdFullScreenTarget))
2106+
(this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget))
20882107
{
20892108
return null;
20902109
}
20912110

20922111
var parentNode = this.game.canvas && this.game.canvas.parentNode;
2112+
20932113
return parentNode || null;
2114+
20942115
}
20952116

20962117
});

src/geom/Line.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
638638
*
639639
* The for the purposes of this function rectangles are considered 'solid'.
640640
*
641-
* @method intersectsRectangle
641+
* @method Phaser.Line.intersectsRectangle
642642
* @param {Phaser.Line} line - The line to check for intersection with.
643643
* @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
644644
* @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.

src/loader/Loader.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,23 @@ Phaser.Loader = function (game) {
106106
* Used to map the application mime-types to to the Accept header in XHR requests.
107107
* If you don't require these mappings, or they cause problems on your server, then
108108
* remove them from the headers object and the XHR request will not try to use them.
109+
*
110+
* This object can also be used to set the `X-Requested-With` header to
111+
* `XMLHttpRequest` (or any other value you need). To enable this do:
112+
*
113+
* `this.load.headers.requestedWith = 'XMLHttpRequest'`
114+
*
115+
* before adding anything to the Loader. The XHR loader will then call:
116+
*
117+
* `setRequestHeader('X-Requested-With', this.headers['requestedWith'])`
118+
*
109119
* @property {object} headers
110120
* @default
111121
*/
112122
this.headers = {
113-
json: "application/json",
114-
xml: "application/xml"
123+
"requestedWith": false,
124+
"json": "application/json",
125+
"xml": "application/xml"
115126
};
116127

117128
/**
@@ -1035,7 +1046,7 @@ Phaser.Loader.prototype = {
10351046
*
10361047
* The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
10371048
*
1038-
* @method Phaser.Loader#audiosprite
1049+
* @method Phaser.Loader#audioSprite
10391050
* @param {string} key - Unique asset key of the audio file.
10401051
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL.
10411052
* @param {string} [jsonURL=null] - The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null.
@@ -2330,9 +2341,14 @@ Phaser.Loader.prototype = {
23302341
xhr.open("GET", url, true);
23312342
xhr.responseType = type;
23322343

2344+
if (this.headers['requestedWith'] !== false)
2345+
{
2346+
xhr.setRequestHeader('X-Requested-With', this.headers['requestedWith']);
2347+
}
2348+
23332349
if (this.headers[file.type])
23342350
{
2335-
xhr.setRequestHeader("Accept", this.headers[file.type]);
2351+
xhr.setRequestHeader('Accept', this.headers[file.type]);
23362352
}
23372353

23382354
onerror = onerror || this.fileError;

src/physics/arcade/Body.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ Phaser.Physics.Arcade.Body.prototype = {
12191219
/**
12201220
* Returns true if the top of this Body is in contact with either the world bounds or a tile.
12211221
*
1222-
* @method Phaser.Physics.Arcade.Body#onTop
1222+
* @method Phaser.Physics.Arcade.Body#onCeiling
12231223
* @return {boolean} True if in contact with either the world bounds or a tile.
12241224
*/
12251225
onCeiling: function(){

src/physics/arcade/World.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,8 +2023,8 @@ Phaser.Physics.Arcade.prototype = {
20232023
*/
20242024
angleBetweenCenters: function (source, target) {
20252025

2026-
var dx = target.center.x - source.center.x;
2027-
var dy = target.center.y - source.center.y;
2026+
var dx = target.centerX - source.centerX;
2027+
var dy = target.centerY - source.centerY;
20282028

20292029
return Math.atan2(dy, dx);
20302030

0 commit comments

Comments
 (0)