phaser-rails 2.0.4.1 → 2.0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Phaser - http://phaser.io
9
9
  *
10
- * v2.0.4 "Mos Shirare" - Built: Tue Apr 29 2014 22:39:37
10
+ * v2.0.5 "Tanchico" - Built: Tue May 20 2014 10:00:53
11
11
  *
12
12
  * By Richard Davey http://www.photonstorm.com @photonstorm
13
13
  *
@@ -9622,29 +9622,55 @@ PIXI.RenderTexture = function(width, height, renderer, scaleMode)
9622
9622
  PIXI.RenderTexture.prototype = Object.create(PIXI.Texture.prototype);
9623
9623
  PIXI.RenderTexture.prototype.constructor = PIXI.RenderTexture;
9624
9624
 
9625
- PIXI.RenderTexture.prototype.resize = function(width, height)
9625
+ /**
9626
+ * Resize the RenderTexture.
9627
+ *
9628
+ * @method resize
9629
+ * @param width {Number} The width to resize to.
9630
+ * @param height {Number} The height to resize to.
9631
+ * @param updateBase {Boolean} Should the baseTexture.width and height values be resized as well?
9632
+ */
9633
+ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
9626
9634
  {
9635
+ if (width === this.width && height === this.height)
9636
+ {
9637
+ return;
9638
+ }
9639
+
9627
9640
  this.width = width;
9628
9641
  this.height = height;
9629
9642
 
9630
9643
  this.frame.width = this.width;
9631
9644
  this.frame.height = this.height;
9632
9645
 
9633
- if(this.renderer.type === PIXI.WEBGL_RENDERER)
9646
+ if (updateBase)
9647
+ {
9648
+ this.baseTexture.width = this.width;
9649
+ this.baseTexture.height = this.height;
9650
+ }
9651
+
9652
+ if (this.renderer.type === PIXI.WEBGL_RENDERER)
9634
9653
  {
9635
9654
  this.projection.x = this.width / 2;
9636
9655
  this.projection.y = -this.height / 2;
9637
-
9638
- var gl = this.renderer.gl;
9639
- gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTextures[gl.id]);
9640
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
9641
9656
  }
9642
- else
9657
+
9658
+ this.textureBuffer.resize(this.width, this.height);
9659
+ };
9660
+
9661
+ /**
9662
+ * Clears the RenderTexture.
9663
+ *
9664
+ * @method clear
9665
+ */
9666
+ PIXI.RenderTexture.prototype.clear = function()
9667
+ {
9668
+ if (this.renderer.type === PIXI.WEBGL_RENDERER)
9643
9669
  {
9644
- this.textureBuffer.resize(this.width, this.height);
9670
+ this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer);
9645
9671
  }
9646
-
9647
- PIXI.Texture.frameUpdates.push(this);
9672
+
9673
+ this.textureBuffer.clear();
9648
9674
  };
9649
9675
 
9650
9676
  /**
@@ -9764,7 +9790,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
9764
9790
  *
9765
9791
  * Phaser - http://phaser.io
9766
9792
  *
9767
- * v2.0.4 "Mos Shirare" - Built: Tue Apr 29 2014 22:39:37
9793
+ * v2.0.5 "Tanchico" - Built: Tue May 20 2014 10:00:53
9768
9794
  *
9769
9795
  * By Richard Davey http://www.photonstorm.com @photonstorm
9770
9796
  *
@@ -9807,7 +9833,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
9807
9833
  */
9808
9834
  var Phaser = Phaser || {
9809
9835
 
9810
- VERSION: '2.0.4',
9836
+ VERSION: '2.0.5',
9811
9837
  GAMES: [],
9812
9838
 
9813
9839
  AUTO: 0,
@@ -9840,6 +9866,7 @@ var Phaser = Phaser || {
9840
9866
  ELLIPSE: 16,
9841
9867
  SPRITEBATCH: 17,
9842
9868
  RETROFONT: 18,
9869
+ POINTER: 19,
9843
9870
 
9844
9871
  // The various blend modes supported by pixi / phaser
9845
9872
  blendModes: {
@@ -9871,10 +9898,10 @@ var Phaser = Phaser || {
9871
9898
 
9872
9899
  };
9873
9900
 
9874
- PIXI.InteractionManager = function () {
9875
- // We don't need this in Pixi, so we've removed it to save space
9876
- // however the Stage object expects a reference to it, so here is a dummy entry.
9877
- };
9901
+ // We don't need this in Pixi, so we've removed it to save space
9902
+ // however the Stage object expects a reference to it, so here is a dummy entry.
9903
+ // Ensure that an existing PIXI.InteractionManager is not overriden - in case you're using your own PIXI library.
9904
+ PIXI.InteractionManager = PIXI.InteractionManager || function () {};
9878
9905
 
9879
9906
  /* jshint supernew: true */
9880
9907
 
@@ -9890,6 +9917,71 @@ PIXI.InteractionManager = function () {
9890
9917
  */
9891
9918
  Phaser.Utils = {
9892
9919
 
9920
+ /**
9921
+ * Transposes the elements of the given Array.
9922
+ *
9923
+ * @method transposeArray
9924
+ * @param {array} array - The array to transpose.
9925
+ * @return {array} The transposed array.
9926
+ */
9927
+ transposeArray: function (array) {
9928
+
9929
+ var result = new Array(array[0].length);
9930
+
9931
+ for (var i = 0; i < array[0].length; i++)
9932
+ {
9933
+ result[i] = new Array(array.length - 1);
9934
+
9935
+ for (var j = array.length - 1; j > -1; j--)
9936
+ {
9937
+ result[i][j] = array[j][i];
9938
+ }
9939
+ }
9940
+
9941
+ return result;
9942
+
9943
+ },
9944
+
9945
+ /**
9946
+ * Rotates the given array.
9947
+ * Based on the routine from http://jsfiddle.net/MrPolywhirl/NH42z/
9948
+ *
9949
+ * @method Phaser.Utils.rotateArray
9950
+ * @param {array} matrix - The array to rotate.
9951
+ * @param {number|string} direction - The amount to rotate. Either a number: 90, -90, 270, -270, 180 or a string: 'rotateLeft', 'rotateRight' or 'rotate180'
9952
+ * @return {array} The rotated array
9953
+ */
9954
+ rotateArray: function (matrix, direction) {
9955
+
9956
+ if (typeof direction !== 'string')
9957
+ {
9958
+ direction = ((direction % 360) + 360) % 360;
9959
+ }
9960
+
9961
+ if (direction === 90 || direction === -270 || direction === 'rotateLeft')
9962
+ {
9963
+ matrix = Phaser.Utils.transposeArray(matrix);
9964
+ matrix = matrix.reverse();
9965
+ }
9966
+ else if (direction === -90 || direction === 270 || direction === 'rotateRight')
9967
+ {
9968
+ matrix = matrix.reverse();
9969
+ matrix = Phaser.Utils.transposeArray(matrix);
9970
+ }
9971
+ else if (Math.abs(direction) === 180 || direction === 'rotate180')
9972
+ {
9973
+ for (var i = 0; i < matrix.length; i++)
9974
+ {
9975
+ matrix[i].reverse();
9976
+ }
9977
+
9978
+ matrix = matrix.reverse();
9979
+ }
9980
+
9981
+ return matrix;
9982
+
9983
+ },
9984
+
9893
9985
  /**
9894
9986
  * Get a unit dimension from a string.
9895
9987
  *
@@ -10424,7 +10516,7 @@ Phaser.Circle.prototype = {
10424
10516
  * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
10425
10517
  * @method Phaser.Circle#circumferencePoint
10426
10518
  * @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
10427
- * @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
10519
+ * @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
10428
10520
  * @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
10429
10521
  * @return {Phaser.Point} The Point object holding the result.
10430
10522
  */
@@ -10725,7 +10817,7 @@ Phaser.Circle.intersects = function (a, b) {
10725
10817
  * @method Phaser.Circle.circumferencePoint
10726
10818
  * @param {Phaser.Circle} a - The first Circle object.
10727
10819
  * @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
10728
- * @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
10820
+ * @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
10729
10821
  * @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
10730
10822
  * @return {Phaser.Point} The Point object holding the result.
10731
10823
  */
@@ -11074,11 +11166,21 @@ Phaser.Point.prototype = {
11074
11166
  *
11075
11167
  * @method Phaser.Point#angle
11076
11168
  * @param {Phaser.Point|any} a - The object to get the angle from this Point to.
11169
+ * @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
11077
11170
  * @return {number} The angle between the two objects.
11078
11171
  */
11079
- angle: function (a) {
11172
+ angle: function (a, asDegrees) {
11080
11173
 
11081
- return Math.atan2(this.x * a.y - this.y * a.x, this.x * a.x + this.y * a.y);
11174
+ if (typeof asDegrees === 'undefined') { asDegrees = false; }
11175
+
11176
+ if (asDegrees)
11177
+ {
11178
+ return Phaser.Math.radToDeg(Math.atan2(a.y - this.y, a.x - this.x));
11179
+ }
11180
+ else
11181
+ {
11182
+ return Math.atan2(a.y - this.y, a.x - this.x);
11183
+ }
11082
11184
 
11083
11185
  },
11084
11186
 
@@ -11362,7 +11464,8 @@ Phaser.Point.equals = function (a, b) {
11362
11464
  */
11363
11465
  Phaser.Point.angle = function (a, b) {
11364
11466
 
11365
- return Math.atan2(a.x * b.y - a.y * b.x, a.x * b.x + a.y * b.y);
11467
+ // return Math.atan2(a.x * b.y - a.y * b.x, a.x * b.x + a.y * b.y);
11468
+ return Math.atan2(a.y - b.y, a.x - b.x);
11366
11469
 
11367
11470
  };
11368
11471
 
@@ -12533,7 +12636,7 @@ Phaser.Line.prototype = {
12533
12636
  */
12534
12637
  pointOnLine: function (x, y) {
12535
12638
 
12536
- return ((x - this.start.x) * (this.end.y - this.end.y) === (this.end.x - this.start.x) * (y - this.end.y));
12639
+ return ((x - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (y - this.start.y));
12537
12640
 
12538
12641
  },
12539
12642
 
@@ -12809,23 +12912,10 @@ Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
12809
12912
 
12810
12913
  if (asSegment)
12811
12914
  {
12812
- if (Math.pow((result.x - b.x) + (result.y - b.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
12813
- {
12814
- return null;
12815
- }
12816
-
12817
- if (Math.pow((result.x - a.x) + (result.y - a.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
12818
- {
12819
- return null;
12820
- }
12821
-
12822
- if (Math.pow((result.x - f.x) + (result.y - f.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
12823
- {
12824
- return null;
12825
- }
12826
-
12827
- if (Math.pow((result.x - e.x) + (result.y - e.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
12828
- {
12915
+ if ( result.x < Math.min(a.x, b.x) || result.x > Math.max(a.x, b.x) ||
12916
+ result.y < Math.min(a.y, b.y) || result.y > Math.max(a.y, b.y) ||
12917
+ result.x < Math.min(e.x, f.x) || result.x > Math.max(e.x, f.x) ||
12918
+ result.y < Math.min(e.y, f.y) || result.y > Math.max(e.y, f.y) ) {
12829
12919
  return null;
12830
12920
  }
12831
12921
  }
@@ -13196,9 +13286,10 @@ Phaser.Polygon = function (points) {
13196
13286
  }
13197
13287
 
13198
13288
  /**
13199
- * @property {array<Phaser.Point>|array<number>} points - The array of Points.
13289
+ * @property {array<Phaser.Point>|array<number>} points - The array of vertex Points.
13290
+ * @private
13200
13291
  */
13201
- this.points = points;
13292
+ this._points = points;
13202
13293
 
13203
13294
  };
13204
13295
 
@@ -13259,6 +13350,95 @@ Phaser.Polygon.prototype = {
13259
13350
 
13260
13351
  Phaser.Polygon.prototype.constructor = Phaser.Polygon;
13261
13352
 
13353
+ /*
13354
+ * Sets and modifies the points of this polygon.
13355
+ *
13356
+ * @name Phaser.Polygon#points
13357
+ * @property {array<Phaser.Point>|array<number>} points - The array of vertex points
13358
+ */
13359
+ Object.defineProperty(Phaser.Polygon.prototype, 'points', {
13360
+
13361
+ get: function() {
13362
+ return this._points;
13363
+ },
13364
+
13365
+ set: function(points) {
13366
+
13367
+ //if points isn't an array, use arguments as the array
13368
+ if (!(points instanceof Array))
13369
+ {
13370
+ points = Array.prototype.slice.call(arguments);
13371
+ }
13372
+
13373
+ //if this is a flat array of numbers, convert it to points
13374
+ if (typeof points[0] === 'number')
13375
+ {
13376
+ var p = [];
13377
+
13378
+ for (var i = 0, len = points.length; i < len; i += 2)
13379
+ {
13380
+ p.push(new Phaser.Point(points[i], points[i + 1]));
13381
+ }
13382
+
13383
+ points = p;
13384
+ }
13385
+
13386
+ this._points = points;
13387
+ }
13388
+
13389
+ });
13390
+
13391
+ /**
13392
+ * Returns the area of the polygon.
13393
+ *
13394
+ * @name Phaser.Circle#right
13395
+ * @readonly
13396
+ */
13397
+ Object.defineProperty(Phaser.Polygon.prototype, 'area', {
13398
+
13399
+ get: function() {
13400
+
13401
+ var p1;
13402
+ var p2;
13403
+ var avgHeight;
13404
+ var width;
13405
+ var i;
13406
+ var y0 = Number.MAX_VALUE;
13407
+ var area = 0;
13408
+
13409
+ // Find lowest boundary
13410
+ for (i = 0; i < this.points.length; i++)
13411
+ {
13412
+ if (this.points[i].y < y0)
13413
+ {
13414
+ y0 = this.points[i].y;
13415
+ }
13416
+ }
13417
+
13418
+ for (i = 0; i< this.points.length; i++)
13419
+ {
13420
+ p1 = this.points[i];
13421
+
13422
+ if (i === this.points.length - 1)
13423
+ {
13424
+ p2 = this.points[0];
13425
+ }
13426
+ else
13427
+ {
13428
+ p2 = this.points[i+1];
13429
+ }
13430
+
13431
+ avgHeight = ((p1.y - y0) + (p2.y - y0)) / 2;
13432
+ width = p1.x - p2.x;
13433
+ area += avgHeight * width;
13434
+ }
13435
+
13436
+ return area;
13437
+
13438
+ }
13439
+
13440
+ });
13441
+
13262
13442
  // Because PIXI uses its own Polygon, we'll replace it with ours to avoid duplicating code or confusion.
13263
13443
  PIXI.Polygon = Phaser.Polygon;
13264
13444
 
@@ -15710,16 +15890,18 @@ Phaser.PluginManager.prototype = {
15710
15890
  *
15711
15891
  * @method Phaser.PluginManager#add
15712
15892
  * @param {object|Phaser.Plugin} plugin - The Plugin to add into the PluginManager. This can be a function or an existing object.
15893
+ * @param {...*} parameter - Additional parameters that will be passed to the Plugin.init method.
15713
15894
  * @return {Phaser.Plugin} The Plugin that was added to the manager.
15714
15895
  */
15715
15896
  add: function (plugin) {
15716
15897
 
15898
+ var args = Array.prototype.splice.call(arguments, 1);
15717
15899
  var result = false;
15718
15900
 
15719
15901
  // Prototype?
15720
15902
  if (typeof plugin === 'function')
15721
15903
  {
15722
- plugin = new plugin(this.game, this._parent);
15904
+ plugin = new plugin(this.game, this);
15723
15905
  }
15724
15906
  else
15725
15907
  {
@@ -15776,7 +15958,7 @@ Phaser.PluginManager.prototype = {
15776
15958
  // Allows plugins to run potentially destructive code outside of the constructor, and only if being added to the PluginManager
15777
15959
  if (typeof plugin['init'] === 'function')
15778
15960
  {
15779
- plugin.init();
15961
+ plugin.init.apply(plugin, args);
15780
15962
  }
15781
15963
 
15782
15964
  return plugin;
@@ -15976,6 +16158,11 @@ Phaser.Stage = function (game, width, height) {
15976
16158
  */
15977
16159
  this.offset = new Phaser.Point();
15978
16160
 
16161
+ /**
16162
+ * @property {Phaser.Rectangle} bounds - The bounds of the Stage. Typically x/y = Stage.offset.x/y and the width/height match the game width and height.
16163
+ */
16164
+ this.bounds = new Phaser.Rectangle(0, 0, width, height);
16165
+
15979
16166
  PIXI.Stage.call(this, 0x000000, false);
15980
16167
 
15981
16168
  /**
@@ -15984,6 +16171,11 @@ Phaser.Stage = function (game, width, height) {
15984
16171
  */
15985
16172
  this.name = '_stage_root';
15986
16173
 
16174
+ /**
16175
+ * @property {boolean} interactive - Pixi level var, ignored by Phaser.
16176
+ * @default
16177
+ * @private
16178
+ */
15987
16179
  this.interactive = false;
15988
16180
 
15989
16181
  /**
@@ -16121,6 +16313,8 @@ Phaser.Stage.prototype.postUpdate = function () {
16121
16313
  if (this.game.time.now > this._nextOffsetCheck)
16122
16314
  {
16123
16315
  Phaser.Canvas.getOffset(this.game.canvas, this.offset);
16316
+ this.bounds.x = this.offset.x;
16317
+ this.bounds.y = this.offset.y;
16124
16318
  this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval;
16125
16319
  }
16126
16320
  }
@@ -16189,7 +16383,7 @@ Phaser.Stage.prototype.boot = function () {
16189
16383
 
16190
16384
  Phaser.Canvas.getOffset(this.game.canvas, this.offset);
16191
16385
 
16192
- this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height);
16386
+ this.bounds.setTo(this.offset.x, this.offset.y, this.game.width, this.game.height);
16193
16387
 
16194
16388
  var _this = this;
16195
16389
 
@@ -16283,18 +16477,27 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
16283
16477
  };
16284
16478
 
16285
16479
  /**
16286
- * Sets the background color for the stage.
16480
+ * Sets the background color for the Stage. The color can be given as a hex value (#RRGGBB) or a numeric value (0xRRGGBB)
16287
16481
  *
16288
16482
  * @name Phaser.Stage#setBackgroundColor
16289
- * @param {number} backgroundColor - The color of the background, easiest way to pass this in is in hex format like: 0xFFFFFF for white.
16483
+ * @param {number|string} backgroundColor - The color of the background.
16290
16484
  */
16291
16485
  Phaser.Stage.prototype.setBackgroundColor = function(backgroundColor)
16292
16486
  {
16293
- this._backgroundColor = backgroundColor || 0x000000;
16294
- this.backgroundColorSplit = PIXI.hex2rgb(this.backgroundColor);
16295
- var hex = this._backgroundColor.toString(16);
16296
- hex = '000000'.substr(0, 6 - hex.length) + hex;
16297
- this.backgroundColorString = '#' + hex;
16487
+ if (typeof backgroundColor === 'string')
16488
+ {
16489
+ var rgb = Phaser.Color.hexToColor(backgroundColor);
16490
+ this._backgroundColor = Phaser.Color.getColor(rgb.r, rgb.g, rgb.b);
16491
+ }
16492
+ else
16493
+ {
16494
+ var rgb = Phaser.Color.getRGB(backgroundColor);
16495
+ this._backgroundColor = backgroundColor;
16496
+ }
16497
+
16498
+ this.backgroundColorSplit = [ rgb.r / 255, rgb.g / 255, rgb.b / 255 ];
16499
+ this.backgroundColorString = Phaser.Color.RGBtoString(rgb.r, rgb.g, rgb.b, 255, '#');
16500
+
16298
16501
  };
16299
16502
 
16300
16503
  /**
@@ -16304,20 +16507,15 @@ Phaser.Stage.prototype.setBackgroundColor = function(backgroundColor)
16304
16507
  Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
16305
16508
 
16306
16509
  get: function () {
16510
+
16307
16511
  return this._backgroundColor;
16512
+
16308
16513
  },
16309
16514
 
16310
16515
  set: function (color) {
16311
16516
 
16312
- this._backgroundColor = color;
16313
-
16314
- if (this.game.transparent === false)
16517
+ if (!this.game.transparent)
16315
16518
  {
16316
- if (typeof color === 'string')
16317
- {
16318
- color = Phaser.Color.hexToRGB(color);
16319
- }
16320
-
16321
16519
  this.setBackgroundColor(color);
16322
16520
  }
16323
16521
 
@@ -16987,15 +17185,57 @@ Phaser.Group.prototype.replace = function (oldChild, newChild) {
16987
17185
  };
16988
17186
 
16989
17187
  /**
16990
- * Sets the given property to the given value on the child. The operation controls the assignment of the value.
17188
+ * Checks if the child has the given property. Will scan up to 4 levels deep only.
17189
+ *
17190
+ * @method Phaser.Group#hasProperty
17191
+ * @param {*} child - The child to check for the existance of the property on.
17192
+ * @param {array} key - An array of strings that make up the property.
17193
+ * @return {boolean} True if the child has the property, otherwise false.
17194
+ */
17195
+ Phaser.Group.prototype.hasProperty = function (child, key) {
17196
+
17197
+ var len = key.length;
17198
+
17199
+ if (len === 1 && key[0] in child)
17200
+ {
17201
+ return true;
17202
+ }
17203
+ else if (len === 2 && key[0] in child && key[1] in child[key[0]])
17204
+ {
17205
+ return true;
17206
+ }
17207
+ else if (len === 3 && key[0] in child && key[1] in child[key[0]] && key[2] in child[key[0]][key[1]])
17208
+ {
17209
+ return true;
17210
+ }
17211
+ else if (len === 4 && key[0] in child && key[1] in child[key[0]] && key[2] in child[key[0]][key[1]] && key[3] in child[key[0]][key[1]][key[2]])
17212
+ {
17213
+ return true;
17214
+ }
17215
+
17216
+ return false;
17217
+
17218
+ };
17219
+
17220
+ /**
17221
+ * Sets a property to the given value on the child. The operation parameter controls how the value is set.
17222
+ * Operation 0 means set the existing value to the given value, or if force is `false` create a new property with the given value.
17223
+ * 1 will add the given value to the value already present.
17224
+ * 2 will subtract the given value from the value already present.
17225
+ * 3 will multiply the value already present by the given value.
17226
+ * 4 will divide the value already present by the given value.
16991
17227
  *
16992
17228
  * @method Phaser.Group#setProperty
16993
17229
  * @param {*} child - The child to set the property value on.
16994
17230
  * @param {array} key - An array of strings that make up the property that will be set.
16995
17231
  * @param {*} value - The value that will be set.
16996
17232
  * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
17233
+ * @param {boolean} [force=false] - If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.
17234
+ * @return {boolean} True if the property was set, false if not.
16997
17235
  */
16998
- Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17236
+ Phaser.Group.prototype.setProperty = function (child, key, value, operation, force) {
17237
+
17238
+ if (typeof force === 'undefined') { force = false; }
16999
17239
 
17000
17240
  operation = operation || 0;
17001
17241
 
@@ -17007,9 +17247,16 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17007
17247
  // 3 = Multiply
17008
17248
  // 4 = Divide
17009
17249
 
17250
+ // We can't force a property in and the child doesn't have it, so abort.
17251
+ // Equally we can't add, subtract, multiply or divide a property value if it doesn't exist, so abort in those cases too.
17252
+ if (!this.hasProperty(child, key) && (!force || operation > 0))
17253
+ {
17254
+ return false;
17255
+ }
17256
+
17010
17257
  var len = key.length;
17011
17258
 
17012
- if (len === 1 && child.hasOwnProperty(key[0]))
17259
+ if (len === 1)
17013
17260
  {
17014
17261
  if (operation === 0) { child[key[0]] = value; }
17015
17262
  else if (operation == 1) { child[key[0]] += value; }
@@ -17017,7 +17264,7 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17017
17264
  else if (operation == 3) { child[key[0]] *= value; }
17018
17265
  else if (operation == 4) { child[key[0]] /= value; }
17019
17266
  }
17020
- else if (len === 2 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]))
17267
+ else if (len === 2)
17021
17268
  {
17022
17269
  if (operation === 0) { child[key[0]][key[1]] = value; }
17023
17270
  else if (operation == 1) { child[key[0]][key[1]] += value; }
@@ -17025,7 +17272,7 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17025
17272
  else if (operation == 3) { child[key[0]][key[1]] *= value; }
17026
17273
  else if (operation == 4) { child[key[0]][key[1]] /= value; }
17027
17274
  }
17028
- else if (len === 3 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]) && child[key[0]][key[1]].hasOwnProperty(key[2]))
17275
+ else if (len === 3)
17029
17276
  {
17030
17277
  if (operation === 0) { child[key[0]][key[1]][key[2]] = value; }
17031
17278
  else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; }
@@ -17033,7 +17280,7 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17033
17280
  else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; }
17034
17281
  else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; }
17035
17282
  }
17036
- else if (len === 4 && child.hasOwnProperty(key[0]) && child[key[0]].hasOwnProperty(key[1]) && child[key[0]][key[1]].hasOwnProperty(key[2]) && child[key[0]][key[1]][key[2]].hasOwnProperty(key[3]))
17283
+ else if (len === 4)
17037
17284
  {
17038
17285
  if (operation === 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
17039
17286
  else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
@@ -17042,6 +17289,8 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17042
17289
  else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
17043
17290
  }
17044
17291
 
17292
+ return true;
17293
+
17045
17294
  };
17046
17295
 
17047
17296
  /**
@@ -17055,8 +17304,12 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
17055
17304
  * @param {boolean} [checkAlive=false] - If set then the child will only be updated if alive=true.
17056
17305
  * @param {boolean} [checkVisible=false] - If set then the child will only be updated if visible=true.
17057
17306
  * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
17307
+ * @param {boolean} [force=false] - If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.
17308
+ * @return {boolean} True if the property was set, false if not.
17058
17309
  */
17059
- Phaser.Group.prototype.set = function (child, key, value, checkAlive, checkVisible, operation) {
17310
+ Phaser.Group.prototype.set = function (child, key, value, checkAlive, checkVisible, operation, force) {
17311
+
17312
+ if (typeof force === 'undefined') { force = false; }
17060
17313
 
17061
17314
  key = key.split('.');
17062
17315
 
@@ -17065,7 +17318,7 @@ Phaser.Group.prototype.set = function (child, key, value, checkAlive, checkVisib
17065
17318
 
17066
17319
  if ((checkAlive === false || (checkAlive && child.alive)) && (checkVisible === false || (checkVisible && child.visible)))
17067
17320
  {
17068
- this.setProperty(child, key, value, operation);
17321
+ return this.setProperty(child, key, value, operation, force);
17069
17322
  }
17070
17323
 
17071
17324
  };
@@ -17083,21 +17336,22 @@ Phaser.Group.prototype.set = function (child, key, value, checkAlive, checkVisib
17083
17336
  * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. This includes any Groups that are children.
17084
17337
  * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. This includes any Groups that are children.
17085
17338
  * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
17339
+ * @param {boolean} [force=false] - If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.
17086
17340
  */
17087
- Phaser.Group.prototype.setAll = function (key, value, checkAlive, checkVisible, operation) {
17088
-
17089
- key = key.split('.');
17341
+ Phaser.Group.prototype.setAll = function (key, value, checkAlive, checkVisible, operation, force) {
17090
17342
 
17091
17343
  if (typeof checkAlive === 'undefined') { checkAlive = false; }
17092
17344
  if (typeof checkVisible === 'undefined') { checkVisible = false; }
17345
+ if (typeof force === 'undefined') { force = false; }
17093
17346
 
17347
+ key = key.split('.');
17094
17348
  operation = operation || 0;
17095
17349
 
17096
17350
  for (var i = 0, len = this.children.length; i < len; i++)
17097
17351
  {
17098
17352
  if ((!checkAlive || (checkAlive && this.children[i].alive)) && (!checkVisible || (checkVisible && this.children[i].visible)))
17099
17353
  {
17100
- this.setProperty(this.children[i], key, value, operation);
17354
+ this.setProperty(this.children[i], key, value, operation, force);
17101
17355
  }
17102
17356
  }
17103
17357
 
@@ -17117,11 +17371,13 @@ Phaser.Group.prototype.setAll = function (key, value, checkAlive, checkVisible,
17117
17371
  * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. This includes any Groups that are children.
17118
17372
  * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. This includes any Groups that are children.
17119
17373
  * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
17374
+ * @param {boolean} [force=false] - If `force` is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.
17120
17375
  */
17121
- Phaser.Group.prototype.setAllChildren = function (key, value, checkAlive, checkVisible, operation) {
17376
+ Phaser.Group.prototype.setAllChildren = function (key, value, checkAlive, checkVisible, operation, force) {
17122
17377
 
17123
17378
  if (typeof checkAlive === 'undefined') { checkAlive = false; }
17124
17379
  if (typeof checkVisible === 'undefined') { checkVisible = false; }
17380
+ if (typeof force === 'undefined') { force = false; }
17125
17381
 
17126
17382
  operation = operation || 0;
17127
17383
 
@@ -17131,11 +17387,11 @@ Phaser.Group.prototype.setAllChildren = function (key, value, checkAlive, checkV
17131
17387
  {
17132
17388
  if (this.children[i] instanceof Phaser.Group)
17133
17389
  {
17134
- this.children[i].setAllChildren(key, value, checkAlive, checkVisible, operation);
17390
+ this.children[i].setAllChildren(key, value, checkAlive, checkVisible, operation, force);
17135
17391
  }
17136
17392
  else
17137
17393
  {
17138
- this.setProperty(this.children[i], key.split('.'), value, operation);
17394
+ this.setProperty(this.children[i], key.split('.'), value, operation, force);
17139
17395
  }
17140
17396
  }
17141
17397
  }
@@ -18489,6 +18745,12 @@ Phaser.ScaleManager = function (game, width, height) {
18489
18745
  */
18490
18746
  this.margin = new Phaser.Point(0, 0);
18491
18747
 
18748
+ /**
18749
+ * @property {Phaser.Rectangle} bounds - The bounds of the scaled game. The x/y will match the offset of the canvas element and the width/height the scaled width and height.
18750
+ * @readonly
18751
+ */
18752
+ this.bounds = new Phaser.Rectangle(0, 0, width, height);
18753
+
18492
18754
  /**
18493
18755
  * @property {number} aspectRatio - The aspect ratio of the scaled game.
18494
18756
  * @readonly
@@ -19001,6 +19263,8 @@ Phaser.ScaleManager.prototype = {
19001
19263
 
19002
19264
  Phaser.Canvas.getOffset(this.game.canvas, this.game.stage.offset);
19003
19265
 
19266
+ this.bounds.setTo(this.game.stage.offset.x, this.game.stage.offset.y, this.width, this.height);
19267
+
19004
19268
  this.aspectRatio = this.width / this.height;
19005
19269
 
19006
19270
  this.scaleFactor.x = this.game.width / this.width;
@@ -19971,6 +20235,11 @@ Phaser.Input = function (game) {
19971
20235
  */
19972
20236
  this.hitContext = null;
19973
20237
 
20238
+ /**
20239
+ * @property {array} moveCallbacks - An array of callbacks that will be fired every time the activePointer receives a move event from the DOM.
20240
+ */
20241
+ this.moveCallbacks = [];
20242
+
19974
20243
  /**
19975
20244
  * @property {function} moveCallback - An optional callback that will be fired every time the activePointer receives a move event from the DOM. Set to null to disable.
19976
20245
  */
@@ -20207,6 +20476,12 @@ Phaser.Input = function (game) {
20207
20476
  */
20208
20477
  this.onHold = null;
20209
20478
 
20479
+ /**
20480
+ * @property {number} minPriorityID - You can tell all Pointers to ignore any object with a priorityID lower than the minPriorityID. Useful when stacking UI layers. Set to zero to disable.
20481
+ * @default
20482
+ */
20483
+ this.minPriorityID = 0;
20484
+
20210
20485
  /**
20211
20486
  * A list of interactive objects. Te InputHandler components add and remove themselves from this.
20212
20487
  * @property {Phaser.ArrayList} interactiveItems
@@ -20324,14 +20599,19 @@ Phaser.Input.prototype = {
20324
20599
  this.gamepad.stop();
20325
20600
  // this.gestures.stop();
20326
20601
 
20602
+ this.moveCallbacks = [];
20603
+ // DEPRECATED
20327
20604
  this.moveCallback = null;
20328
20605
 
20329
20606
  },
20330
20607
 
20331
20608
  /**
20609
+ * DEPRECATED: This method will be removed in a future major point release. Please use Input.addMoveCallback instead.
20610
+ *
20332
20611
  * Sets a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove.
20333
20612
  * It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best
20334
20613
  * to only use if you've limited input to a single pointer (i.e. mouse or touch)
20614
+ *
20335
20615
  * @method Phaser.Input#setMoveCallback
20336
20616
  * @param {function} callback - The callback that will be called each time the activePointer receives a DOM move event.
20337
20617
  * @param {object} callbackContext - The context in which the callback will be called.
@@ -20343,6 +20623,41 @@ Phaser.Input.prototype = {
20343
20623
 
20344
20624
  },
20345
20625
 
20626
+ /**
20627
+ * Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove.
20628
+ * It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best
20629
+ * to only use if you've limited input to a single pointer (i.e. mouse or touch).
20630
+ * The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback.
20631
+ *
20632
+ * @method Phaser.Input#addMoveCallback
20633
+ * @param {function} callback - The callback that will be called each time the activePointer receives a DOM move event.
20634
+ * @param {object} callbackContext - The context in which the callback will be called.
20635
+ * @return {number} The index of the callback entry. Use this index when calling Input.deleteMoveCallback.
20636
+ */
20637
+ addMoveCallback: function (callback, callbackContext) {
20638
+
20639
+ return this.moveCallbacks.push( { callback: callback, context: callbackContext }) - 1;
20640
+
20641
+ },
20642
+
20643
+ /**
20644
+ * Adds a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove.
20645
+ * It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best
20646
+ * to only use if you've limited input to a single pointer (i.e. mouse or touch).
20647
+ * The callback is added to the Phaser.Input.moveCallbacks array and should be removed with Phaser.Input.deleteMoveCallback.
20648
+ *
20649
+ * @method Phaser.Input#deleteMoveCallback
20650
+ * @param {number} index - The index of the callback to remove.
20651
+ */
20652
+ deleteMoveCallback: function (index) {
20653
+
20654
+ if (this.moveCallbacks[index])
20655
+ {
20656
+ this.moveCallbacks.splice(index, 1);
20657
+ }
20658
+
20659
+ },
20660
+
20346
20661
  /**
20347
20662
  * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2.
20348
20663
  * If you need more then use this to create a new one, up to a maximum of 10.
@@ -20461,6 +20776,7 @@ Phaser.Input.prototype = {
20461
20776
  this.onUp = new Phaser.Signal();
20462
20777
  this.onTap = new Phaser.Signal();
20463
20778
  this.onHold = new Phaser.Signal();
20779
+ this.moveCallbacks = [];
20464
20780
  }
20465
20781
 
20466
20782
  this._pollCounter = 0;
@@ -20612,18 +20928,56 @@ Phaser.Input.prototype = {
20612
20928
  },
20613
20929
 
20614
20930
  /**
20615
- * Get the Pointer object whos identified property matches the given identifier value.
20931
+ * Get the Pointer object whos `identifier` property matches the given identifier value.
20932
+ * The identifier property is not set until the Pointer has been used at least once, as its populated by the DOM event.
20933
+ * Also it can change every time you press the pointer down, and is not fixed once set.
20934
+ * Note: Not all browsers set the identifier property and it's not part of the W3C spec, so you may need getPointerFromId instead.
20935
+ *
20616
20936
  * @method Phaser.Input#getPointerFromIdentifier
20617
20937
  * @param {number} identifier - The Pointer.identifier value to search for.
20618
20938
  * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
20619
20939
  */
20620
20940
  getPointerFromIdentifier: function (identifier) {
20621
20941
 
20622
- if (this.pointer1.identifier == identifier)
20942
+ if (this.pointer1.identifier === identifier)
20943
+ {
20944
+ return this.pointer1;
20945
+ }
20946
+ else if (this.pointer2.identifier === identifier)
20947
+ {
20948
+ return this.pointer2;
20949
+ }
20950
+ else
20951
+ {
20952
+ for (var i = 3; i <= 10; i++)
20953
+ {
20954
+ if (this['pointer' + i] && this['pointer' + i].identifier === identifier)
20955
+ {
20956
+ return this['pointer' + i];
20957
+ }
20958
+ }
20959
+ }
20960
+
20961
+ return null;
20962
+
20963
+ },
20964
+
20965
+ /**
20966
+ * Get the Pointer object whos `pointerId` property matches the given value.
20967
+ * The pointerId property is not set until the Pointer has been used at least once, as its populated by the DOM event.
20968
+ * Also it can change every time you press the pointer down if the browser recycles it.
20969
+ *
20970
+ * @method Phaser.Input#getPointerFromId
20971
+ * @param {number} pointerId - The Pointer.pointerId value to search for.
20972
+ * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
20973
+ */
20974
+ getPointerFromId: function (pointerId) {
20975
+
20976
+ if (this.pointer1.pointerId === pointerId)
20623
20977
  {
20624
20978
  return this.pointer1;
20625
20979
  }
20626
- else if (this.pointer2.identifier == identifier)
20980
+ else if (this.pointer2.pointerId === pointerId)
20627
20981
  {
20628
20982
  return this.pointer2;
20629
20983
  }
@@ -20631,7 +20985,7 @@ Phaser.Input.prototype = {
20631
20985
  {
20632
20986
  for (var i = 3; i <= 10; i++)
20633
20987
  {
20634
- if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
20988
+ if (this['pointer' + i] && this['pointer' + i].pointerId === pointerId)
20635
20989
  {
20636
20990
  return this['pointer' + i];
20637
20991
  }
@@ -21072,12 +21426,12 @@ Phaser.Key.prototype = {
21072
21426
  /**
21073
21427
  * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
21074
21428
  * @method Phaser.Key#justPressed
21075
- * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
21429
+ * @param {number} [duration=50] - The duration below which the key is considered as being just pressed.
21076
21430
  * @return {boolean} True if the key is just pressed otherwise false.
21077
21431
  */
21078
21432
  justPressed: function (duration) {
21079
21433
 
21080
- if (typeof duration === "undefined") { duration = 2500; }
21434
+ if (typeof duration === "undefined") { duration = 50; }
21081
21435
 
21082
21436
  return (this.isDown && this.duration < duration);
21083
21437
 
@@ -21086,12 +21440,12 @@ Phaser.Key.prototype = {
21086
21440
  /**
21087
21441
  * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
21088
21442
  * @method Phaser.Key#justReleased
21089
- * @param {number} [duration=250] - The duration below which the key is considered as being just released.
21443
+ * @param {number} [duration=50] - The duration below which the key is considered as being just released.
21090
21444
  * @return {boolean} True if the key is just released otherwise false.
21091
21445
  */
21092
21446
  justReleased: function (duration) {
21093
21447
 
21094
- if (typeof duration === "undefined") { duration = 2500; }
21448
+ if (typeof duration === "undefined") { duration = 50; }
21095
21449
 
21096
21450
  return (!this.isDown && ((this.game.time.now - this.timeUp) < duration));
21097
21451
 
@@ -21489,11 +21843,13 @@ Phaser.Keyboard.prototype = {
21489
21843
  *
21490
21844
  * @method Phaser.Keyboard#justPressed
21491
21845
  * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
21492
- * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
21846
+ * @param {number} [duration=50] - The duration below which the key is considered as being just pressed.
21493
21847
  * @return {boolean} True if the key is just pressed otherwise false.
21494
21848
  */
21495
21849
  justPressed: function (keycode, duration) {
21496
21850
 
21851
+ if (typeof duration === 'undefined') { duration = 50; }
21852
+
21497
21853
  if (this._keys[keycode])
21498
21854
  {
21499
21855
  return this._keys[keycode].justPressed(duration);
@@ -21510,11 +21866,13 @@ Phaser.Keyboard.prototype = {
21510
21866
  *
21511
21867
  * @method Phaser.Keyboard#justReleased
21512
21868
  * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
21513
- * @param {number} [duration=250] - The duration below which the key is considered as being just released.
21869
+ * @param {number} [duration=50] - The duration below which the key is considered as being just released.
21514
21870
  * @return {boolean} True if the key is just released otherwise false.
21515
21871
  */
21516
21872
  justReleased: function (keycode, duration) {
21517
21873
 
21874
+ if (typeof duration === 'undefined') { duration = 50; }
21875
+
21518
21876
  if (this._keys[keycode])
21519
21877
  {
21520
21878
  return this._keys[keycode].justReleased(duration);
@@ -21687,6 +22045,16 @@ Phaser.Mouse = function (game) {
21687
22045
  */
21688
22046
  this.mouseUpCallback = null;
21689
22047
 
22048
+ /**
22049
+ * @property {function} mouseOutCallback - A callback that can be fired when the mouse is no longer over the game canvas.
22050
+ */
22051
+ this.mouseOutCallback = null;
22052
+
22053
+ /**
22054
+ * @property {function} mouseOverCallback - A callback that can be fired when the mouse enters the game canvas (usually after a mouseout).
22055
+ */
22056
+ this.mouseOverCallback = null;
22057
+
21690
22058
  /**
21691
22059
  * @property {boolean} capture - If true the DOM mouse events will have event.preventDefault applied to them, if false they will propogate fully.
21692
22060
  */
@@ -21710,6 +22078,12 @@ Phaser.Mouse = function (game) {
21710
22078
  */
21711
22079
  this.locked = false;
21712
22080
 
22081
+ /**
22082
+ * @property {boolean} stopOnGameOut - If true Pointer.stop will be called if the mouse leaves the game canvas.
22083
+ * @default
22084
+ */
22085
+ this.stopOnGameOut = false;
22086
+
21713
22087
  /**
21714
22088
  * @property {Phaser.Signal} pointerLock - This event is dispatched when the browser enters or leaves pointer lock state.
21715
22089
  * @default
@@ -21740,6 +22114,18 @@ Phaser.Mouse = function (game) {
21740
22114
  */
21741
22115
  this._onMouseUp = null;
21742
22116
 
22117
+ /**
22118
+ * @property {function} _onMouseOut - Internal event handler reference.
22119
+ * @private
22120
+ */
22121
+ this._onMouseOut = null;
22122
+
22123
+ /**
22124
+ * @property {function} _onMouseOver - Internal event handler reference.
22125
+ * @private
22126
+ */
22127
+ this._onMouseOver = null;
22128
+
21743
22129
  };
21744
22130
 
21745
22131
  /**
@@ -21800,9 +22186,19 @@ Phaser.Mouse.prototype = {
21800
22186
  return _this.onMouseUp(event);
21801
22187
  };
21802
22188
 
22189
+ this._onMouseOut = function (event) {
22190
+ return _this.onMouseOut(event);
22191
+ };
22192
+
22193
+ this._onMouseOver = function (event) {
22194
+ return _this.onMouseOver(event);
22195
+ };
22196
+
21803
22197
  this.game.canvas.addEventListener('mousedown', this._onMouseDown, true);
21804
22198
  this.game.canvas.addEventListener('mousemove', this._onMouseMove, true);
21805
22199
  this.game.canvas.addEventListener('mouseup', this._onMouseUp, true);
22200
+ this.game.canvas.addEventListener('mouseover', this._onMouseOver, true);
22201
+ this.game.canvas.addEventListener('mouseout', this._onMouseOut, true);
21806
22202
 
21807
22203
  },
21808
22204
 
@@ -21900,6 +22296,71 @@ Phaser.Mouse.prototype = {
21900
22296
 
21901
22297
  },
21902
22298
 
22299
+ /**
22300
+ * The internal method that handles the mouse out event from the browser.
22301
+ *
22302
+ * @method Phaser.Mouse#onMouseOut
22303
+ * @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
22304
+ */
22305
+ onMouseOut: function (event) {
22306
+
22307
+ this.event = event;
22308
+
22309
+ if (this.capture)
22310
+ {
22311
+ event.preventDefault();
22312
+ }
22313
+
22314
+ if (this.mouseOutCallback)
22315
+ {
22316
+ this.mouseOutCallback.call(this.callbackContext, event);
22317
+ }
22318
+
22319
+ if (this.game.input.disabled || this.disabled)
22320
+ {
22321
+ return;
22322
+ }
22323
+
22324
+ this.game.input.mousePointer.withinGame = false;
22325
+
22326
+ if (this.stopOnGameOut)
22327
+ {
22328
+ event['identifier'] = 0;
22329
+
22330
+ this.game.input.mousePointer.stop(event);
22331
+ }
22332
+
22333
+ },
22334
+
22335
+ /**
22336
+ * The internal method that handles the mouse over event from the browser.
22337
+ *
22338
+ * @method Phaser.Mouse#onMouseOver
22339
+ * @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
22340
+ */
22341
+ onMouseOver: function (event) {
22342
+
22343
+ this.event = event;
22344
+
22345
+ if (this.capture)
22346
+ {
22347
+ event.preventDefault();
22348
+ }
22349
+
22350
+ if (this.mouseOverCallback)
22351
+ {
22352
+ this.mouseOverCallback.call(this.callbackContext, event);
22353
+ }
22354
+
22355
+ if (this.game.input.disabled || this.disabled)
22356
+ {
22357
+ return;
22358
+ }
22359
+
22360
+ this.game.input.mousePointer.withinGame = true;
22361
+
22362
+ },
22363
+
21903
22364
  /**
21904
22365
  * If the browser supports it you can request that the pointer be locked to the browser window.
21905
22366
  * This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key.
@@ -21978,6 +22439,8 @@ Phaser.Mouse.prototype = {
21978
22439
  this.game.canvas.removeEventListener('mousedown', this._onMouseDown, true);
21979
22440
  this.game.canvas.removeEventListener('mousemove', this._onMouseMove, true);
21980
22441
  this.game.canvas.removeEventListener('mouseup', this._onMouseUp, true);
22442
+ this.game.canvas.removeEventListener('mouseover', this._onMouseOver, true);
22443
+ this.game.canvas.removeEventListener('mouseout', this._onMouseOut, true);
21981
22444
 
21982
22445
  }
21983
22446
 
@@ -22189,6 +22652,42 @@ Phaser.Pointer = function (game, id) {
22189
22652
  */
22190
22653
  this.id = id;
22191
22654
 
22655
+ /**
22656
+ * @property {number} type - The const type of this object.
22657
+ * @readonly
22658
+ */
22659
+ this.type = Phaser.POINTER;
22660
+
22661
+ /**
22662
+ * @property {boolean} exists - A Pointer object that exists is allowed to be checked for physics collisions and overlaps.
22663
+ * @default
22664
+ */
22665
+ this.exists = true;
22666
+
22667
+ /**
22668
+ * @property {number} identifier - The identifier property of the Pointer as set by the DOM event when this Pointer is started.
22669
+ * @default
22670
+ */
22671
+ this.identifier = 0;
22672
+
22673
+ /**
22674
+ * @property {number} pointerId - The pointerId property of the Pointer as set by the DOM event when this Pointer is started. The browser can and will recycle this value.
22675
+ * @default
22676
+ */
22677
+ this.pointerId = null;
22678
+
22679
+ /**
22680
+ * @property {any} target - The target property of the Pointer as set by the DOM event when this Pointer is started.
22681
+ * @default
22682
+ */
22683
+ this.target = null;
22684
+
22685
+ /**
22686
+ * @property {any} button - The button property of the Pointer as set by the DOM event when this Pointer is started.
22687
+ * @default
22688
+ */
22689
+ this.button = null;
22690
+
22192
22691
  /**
22193
22692
  * @property {boolean} _holdSent - Local private variable to store the status of dispatching a hold event.
22194
22693
  * @private
@@ -22203,68 +22702,84 @@ Phaser.Pointer = function (game, id) {
22203
22702
  this._history = [];
22204
22703
 
22205
22704
  /**
22206
- * @property {number} _lastDrop - Local private variable storing the time at which the next history drop should occur.
22705
+ * @property {number} _nextDrop - Local private variable storing the time at which the next history drop should occur.
22207
22706
  * @private
22208
- * @default
22209
22707
  */
22210
22708
  this._nextDrop = 0;
22211
22709
 
22212
22710
  /**
22213
22711
  * @property {boolean} _stateReset - Monitor events outside of a state reset loop.
22214
22712
  * @private
22215
- * @default
22216
22713
  */
22217
22714
  this._stateReset = false;
22218
22715
 
22219
22716
  /**
22220
- * @property {boolean} withinGame - true if the Pointer is within the game area, otherwise false.
22717
+ * @property {boolean} withinGame - true if the Pointer is over the game canvas, otherwise false.
22221
22718
  */
22222
22719
  this.withinGame = false;
22223
22720
 
22224
22721
  /**
22225
- * @property {number} clientX - The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset.
22226
- * @default
22722
+ * @property {number} clientX - The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
22227
22723
  */
22228
22724
  this.clientX = -1;
22229
22725
 
22230
22726
  /**
22231
- * @property {number} clientY - The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset.
22232
- * @default
22727
+ * @property {number} clientY - The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
22233
22728
  */
22234
22729
  this.clientY = -1;
22235
22730
 
22236
22731
  /**
22237
- * @property {number} pageX - The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset.
22238
- * @default
22732
+ * @property {number} pageX - The horizontal coordinate of the Pointer relative to whole document.
22239
22733
  */
22240
22734
  this.pageX = -1;
22241
22735
 
22242
22736
  /**
22243
- * @property {number} pageY - The vertical coordinate of point relative to the viewport in pixels, including any scroll offset.
22244
- * @default
22737
+ * @property {number} pageY - The vertical coordinate of the Pointer relative to whole document.
22245
22738
  */
22246
22739
  this.pageY = -1;
22247
22740
 
22248
22741
  /**
22249
- * @property {number} screenX - The horizontal coordinate of point relative to the screen in pixels.
22250
- * @default
22742
+ * @property {number} screenX - The horizontal coordinate of the Pointer relative to the screen.
22251
22743
  */
22252
22744
  this.screenX = -1;
22253
22745
 
22254
22746
  /**
22255
- * @property {number} screenY - The vertical coordinate of point relative to the screen in pixels.
22256
- * @default
22747
+ * @property {number} screenY - The vertical coordinate of the Pointer relative to the screen.
22257
22748
  */
22258
22749
  this.screenY = -1;
22259
22750
 
22260
22751
  /**
22261
- * @property {number} x - The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
22752
+ * @property {number} rawMovementX - The horizontal raw relative movement of the Pointer in pixels since last event.
22753
+ * @default
22754
+ */
22755
+ this.rawMovementX = 0;
22756
+
22757
+ /**
22758
+ * @property {number} rawMovementY - The vertical raw relative movement of the Pointer in pixels since last event.
22759
+ * @default
22760
+ */
22761
+ this.rawMovementY = 0;
22762
+
22763
+ /**
22764
+ * @property {number} movementX - The horizontal processed relative movement of the Pointer in pixels since last event.
22765
+ * @default
22766
+ */
22767
+ this.movementX = 0;
22768
+
22769
+ /**
22770
+ * @property {number} movementY - The vertical processed relative movement of the Pointer in pixels since last event.
22771
+ * @default
22772
+ */
22773
+ this.movementY = 0;
22774
+
22775
+ /**
22776
+ * @property {number} x - The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale.
22262
22777
  * @default
22263
22778
  */
22264
22779
  this.x = -1;
22265
22780
 
22266
22781
  /**
22267
- * @property {number} y - The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
22782
+ * @property {number} y - The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale.
22268
22783
  * @default
22269
22784
  */
22270
22785
  this.y = -1;
@@ -22312,7 +22827,7 @@ Phaser.Pointer = function (game, id) {
22312
22827
  this.totalTouches = 0;
22313
22828
 
22314
22829
  /**
22315
- * @property {number} msSinceLastClick - The number of miliseconds since the last click.
22830
+ * @property {number} msSinceLastClick - The number of milliseconds since the last click or touch event.
22316
22831
  * @default
22317
22832
  */
22318
22833
  this.msSinceLastClick = Number.MAX_VALUE;
@@ -22363,10 +22878,15 @@ Phaser.Pointer.prototype = {
22363
22878
  /**
22364
22879
  * Called when the Pointer is pressed onto the touchscreen.
22365
22880
  * @method Phaser.Pointer#start
22366
- * @param {Any} event
22881
+ * @param {any} event - The DOM event from the browser.
22367
22882
  */
22368
22883
  start: function (event) {
22369
22884
 
22885
+ if (event['pointerId'])
22886
+ {
22887
+ this.pointerId = event.pointerId;
22888
+ }
22889
+
22370
22890
  this.identifier = event.identifier;
22371
22891
  this.target = event.target;
22372
22892
 
@@ -22484,6 +23004,15 @@ Phaser.Pointer.prototype = {
22484
23004
  this.screenX = event.screenX;
22485
23005
  this.screenY = event.screenY;
22486
23006
 
23007
+ if (this.isMouse && this.game.input.mouse.locked && !fromClick)
23008
+ {
23009
+ this.rawMovementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
23010
+ this.rawMovementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
23011
+
23012
+ this.movementX += this.rawMovementX;
23013
+ this.movementY += this.rawMovementY;
23014
+ }
23015
+
22487
23016
  this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
22488
23017
  this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
22489
23018
 
@@ -22491,7 +23020,7 @@ Phaser.Pointer.prototype = {
22491
23020
  this.circle.x = this.x;
22492
23021
  this.circle.y = this.y;
22493
23022
 
22494
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
23023
+ if (this.game.input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
22495
23024
  {
22496
23025
  this.game.input.activePointer = this;
22497
23026
  this.game.input.x = this.x;
@@ -22501,17 +23030,27 @@ Phaser.Pointer.prototype = {
22501
23030
  this.game.input.circle.y = this.game.input.y;
22502
23031
  }
22503
23032
 
23033
+ this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY);
23034
+
22504
23035
  // If the game is paused we don't process any target objects or callbacks
22505
23036
  if (this.game.paused)
22506
23037
  {
22507
23038
  return this;
22508
23039
  }
22509
23040
 
23041
+ // DEPRECATED - Soon to be removed
22510
23042
  if (this.game.input.moveCallback)
22511
23043
  {
22512
23044
  this.game.input.moveCallback.call(this.game.input.moveCallbackContext, this, this.x, this.y);
22513
23045
  }
22514
23046
 
23047
+ var i = this.game.input.moveCallbacks.length;
23048
+
23049
+ while (i--)
23050
+ {
23051
+ this.game.input.moveCallbacks[i].callback.call(this.game.input.moveCallbacks[i].context, this, this.x, this.y);
23052
+ }
23053
+
22515
23054
  // Easy out if we're dragging something and it still exists
22516
23055
  if (this.targetObject !== null && this.targetObject.isDragged === true)
22517
23056
  {
@@ -22601,6 +23140,7 @@ Phaser.Pointer.prototype = {
22601
23140
 
22602
23141
  /**
22603
23142
  * Called when the Pointer leaves the target area.
23143
+ *
22604
23144
  * @method Phaser.Pointer#leave
22605
23145
  * @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
22606
23146
  */
@@ -22613,6 +23153,7 @@ Phaser.Pointer.prototype = {
22613
23153
 
22614
23154
  /**
22615
23155
  * Called when the Pointer leaves the touchscreen.
23156
+ *
22616
23157
  * @method Phaser.Pointer#stop
22617
23158
  * @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
22618
23159
  */
@@ -22626,7 +23167,7 @@ Phaser.Pointer.prototype = {
22626
23167
 
22627
23168
  this.timeUp = this.game.time.now;
22628
23169
 
22629
- if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
23170
+ if (this.game.input.multiInputOverride === Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride === Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride === Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
22630
23171
  {
22631
23172
  this.game.input.onUp.dispatch(this, event);
22632
23173
 
@@ -22658,6 +23199,8 @@ Phaser.Pointer.prototype = {
22658
23199
  this.withinGame = false;
22659
23200
  this.isDown = false;
22660
23201
  this.isUp = true;
23202
+ this.pointerId = null;
23203
+ this.identifier = null;
22661
23204
 
22662
23205
  this.positionUp.setTo(this.x, this.y);
22663
23206
 
@@ -22717,6 +23260,7 @@ Phaser.Pointer.prototype = {
22717
23260
  this.active = false;
22718
23261
  }
22719
23262
 
23263
+ this.pointerId = null;
22720
23264
  this.identifier = null;
22721
23265
  this.isDown = false;
22722
23266
  this.isUp = true;
@@ -22732,6 +23276,17 @@ Phaser.Pointer.prototype = {
22732
23276
 
22733
23277
  this.targetObject = null;
22734
23278
 
23279
+ },
23280
+
23281
+ /**
23282
+ * Resets the movementX and movementY properties. Use in your update handler after retrieving the values.
23283
+ * @method Phaser.Pointer#resetMovement
23284
+ */
23285
+ resetMovement: function() {
23286
+
23287
+ this.movementX = 0;
23288
+ this.movementY = 0;
23289
+
22735
23290
  }
22736
23291
 
22737
23292
  };
@@ -23051,6 +23606,8 @@ Phaser.Touch.prototype = {
23051
23606
  */
23052
23607
  onTouchEnter: function (event) {
23053
23608
 
23609
+ console.log('touch enter', event);
23610
+
23054
23611
  this.event = event;
23055
23612
 
23056
23613
  if (this.touchEnterCallback)
@@ -23182,8 +23739,7 @@ Phaser.Touch.prototype.constructor = Phaser.Touch;
23182
23739
  * HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE!
23183
23740
  * At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it
23184
23741
  * via prefs flags (about:config, search gamepad). The browsers map the same controllers differently.
23185
- * This class has constans for Windows 7 Chrome mapping of
23186
- * XBOX 360 controller.
23742
+ * This class has constants for Windows 7 Chrome mapping of XBOX 360 controller.
23187
23743
  *
23188
23744
  * @class Phaser.Gamepad
23189
23745
  * @constructor
@@ -24668,6 +25224,12 @@ Phaser.InputHandler = function (sprite) {
24668
25224
  */
24669
25225
  this.consumePointerEvent = false;
24670
25226
 
25227
+ /**
25228
+ * @property {boolean} _dragPhase - Internal cache var.
25229
+ * @private
25230
+ */
25231
+ this._dragPhase = false;
25232
+
24671
25233
  /**
24672
25234
  * @property {boolean} _wasEnabled - Internal cache var.
24673
25235
  * @private
@@ -24776,6 +25338,11 @@ Phaser.InputHandler.prototype = {
24776
25338
  */
24777
25339
  addedToGroup: function () {
24778
25340
 
25341
+ if (this._dragPhase)
25342
+ {
25343
+ return;
25344
+ }
25345
+
24779
25346
  if (this._wasEnabled && !this.enabled)
24780
25347
  {
24781
25348
  this.start();
@@ -24791,6 +25358,11 @@ Phaser.InputHandler.prototype = {
24791
25358
  */
24792
25359
  removedFromGroup: function () {
24793
25360
 
25361
+ if (this._dragPhase)
25362
+ {
25363
+ return;
25364
+ }
25365
+
24794
25366
  if (this.enabled)
24795
25367
  {
24796
25368
  this._wasEnabled = true;
@@ -24889,7 +25461,7 @@ Phaser.InputHandler.prototype = {
24889
25461
  */
24890
25462
  validForInput: function (highestID, highestRenderID) {
24891
25463
 
24892
- if (this.sprite.scale.x === 0 || this.sprite.scale.y === 0)
25464
+ if (this.sprite.scale.x === 0 || this.sprite.scale.y === 0 || this.priorityID < this.game.input.minPriorityID)
24893
25465
  {
24894
25466
  return false;
24895
25467
  }
@@ -25410,7 +25982,7 @@ Phaser.InputHandler.prototype = {
25410
25982
  }
25411
25983
 
25412
25984
  // Stop drag
25413
- if (this.draggable && this.isDragged && this._draggedPointerID == pointer.id)
25985
+ if (this.draggable && this.isDragged && this._draggedPointerID === pointer.id)
25414
25986
  {
25415
25987
  this.stopDrag(pointer);
25416
25988
  }
@@ -25697,6 +26269,7 @@ Phaser.InputHandler.prototype = {
25697
26269
 
25698
26270
  if (this.bringToTop)
25699
26271
  {
26272
+ this._dragPhase = true;
25700
26273
  this.sprite.bringToTop();
25701
26274
  }
25702
26275
 
@@ -25714,6 +26287,7 @@ Phaser.InputHandler.prototype = {
25714
26287
  this.isDragged = false;
25715
26288
  this._draggedPointerID = -1;
25716
26289
  this._pointerData[pointer.id].isDragged = false;
26290
+ this._dragPhase = false;
25717
26291
 
25718
26292
  if (this.snapOnRelease)
25719
26293
  {
@@ -27098,7 +27672,7 @@ Phaser.BitmapData.prototype = {
27098
27672
 
27099
27673
  result = callback.call(callbackContext, pixel, tx, ty);
27100
27674
 
27101
- if (result !== false && result !== null)
27675
+ if (result !== false && result !== null && result !== undefined)
27102
27676
  {
27103
27677
  this.setPixel32(tx, ty, result.r, result.g, result.b, result.a, false);
27104
27678
  dirty = true;
@@ -27386,6 +27960,8 @@ Phaser.BitmapData.prototype = {
27386
27960
 
27387
27961
  /**
27388
27962
  * Get the color of a specific pixel in the context into a color object.
27963
+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
27964
+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
27389
27965
  *
27390
27966
  * @method Phaser.BitmapData#getPixel
27391
27967
  * @param {number} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData.
@@ -27418,6 +27994,8 @@ Phaser.BitmapData.prototype = {
27418
27994
 
27419
27995
  /**
27420
27996
  * Get the color of a specific pixel including its alpha value.
27997
+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
27998
+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
27421
27999
  * Note that on little-endian systems the format is 0xAABBGGRR and on big-endian the format is 0xRRGGBBAA.
27422
28000
  *
27423
28001
  * @method Phaser.BitmapData#getPixel32
@@ -27436,6 +28014,8 @@ Phaser.BitmapData.prototype = {
27436
28014
 
27437
28015
  /**
27438
28016
  * Get the color of a specific pixel including its alpha value as a color object containing r,g,b,a and rgba properties.
28017
+ * If you have drawn anything to the BitmapData since it was created you must call BitmapData.update to refresh the array buffer,
28018
+ * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist.
27439
28019
  *
27440
28020
  * @method Phaser.BitmapData#getPixelRGB
27441
28021
  * @param {number} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this BitmapData.
@@ -27611,13 +28191,35 @@ Phaser.BitmapData.prototype = {
27611
28191
 
27612
28192
  },
27613
28193
 
28194
+ /**
28195
+ * Draws a filled Rectangle to the BitmapData at the given x, y coordinates and width / height in size.
28196
+ *
28197
+ * @method Phaser.BitmapData#rect
28198
+ * @param {number} x - The x coordinate of the top-left of the Rectangle.
28199
+ * @param {number} y - The y coordinate of the top-left of the Rectangle.
28200
+ * @param {number} width - The width of the Rectangle.
28201
+ * @param {number} height - The height of the Rectangle.
28202
+ * @param {string} [fillStyle] - If set the context fillStyle will be set to this value before the rect is drawn.
28203
+ */
28204
+ rect: function (x, y, width, height, fillStyle) {
28205
+
28206
+ if (typeof fillStyle !== 'undefined')
28207
+ {
28208
+ this.context.fillStyle = fillStyle;
28209
+ }
28210
+
28211
+ this.context.fillRect(x, y, width, height);
28212
+ this.context.fill();
28213
+
28214
+ },
28215
+
27614
28216
  /**
27615
28217
  * Draws a filled Circle to the BitmapData at the given x, y coordinates and radius in size.
27616
28218
  *
27617
28219
  * @method Phaser.BitmapData#circle
27618
- * @param {number} x - The x coordinate to draw the Circle at.
27619
- * @param {number} y - The y coordinate to draw the Circle at.
27620
- * @param {number} radius - The radius of the Circle.
28220
+ * @param {number} x - The x coordinate to draw the Circle at. This is the center of the circle.
28221
+ * @param {number} y - The y coordinate to draw the Circle at. This is the center of the circle.
28222
+ * @param {number} radius - The radius of the Circle in pixels. The radius is half the diameter.
27621
28223
  * @param {string} [fillStyle] - If set the context fillStyle will be set to this value before the circle is drawn.
27622
28224
  */
27623
28225
  circle: function (x, y, radius, fillStyle) {
@@ -28071,6 +28673,9 @@ Phaser.Sprite.prototype.loadTexture = function (key, frame) {
28071
28673
  * Crop allows you to crop the texture used to display this Sprite.
28072
28674
  * Cropping takes place from the top-left of the Sprite and can be modified in real-time by providing an updated rectangle object.
28073
28675
  * Note that cropping a Sprite will reset its animation to the first frame. You cannot currently crop an animated Sprite.
28676
+ * The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
28677
+ * Please note that the rectangle object given is not duplicated by this method, but rather the Image uses a reference to the rectangle.
28678
+ * Keep this in mind if assigning a rectangle in a for-loop, or when cleaning up for garbage collection.
28074
28679
  *
28075
28680
  * @method Phaser.Sprite#crop
28076
28681
  * @memberof Phaser.Sprite
@@ -28755,7 +29360,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "destroyPhase", {
28755
29360
  *
28756
29361
  * @constructor
28757
29362
  * @param {Phaser.Game} game - A reference to the currently running game.
28758
- * @param {number} x - The x coordinate of the Imaget. The coordinate is relative to any parent container this Image may be in.
29363
+ * @param {number} x - The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
28759
29364
  * @param {number} y - The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
28760
29365
  * @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - The texture used by the Image during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture.
28761
29366
  * @param {string|number} frame - If this Image is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
@@ -29028,10 +29633,13 @@ Phaser.Image.prototype.loadTexture = function (key, frame) {
29028
29633
  /**
29029
29634
  * Crop allows you to crop the texture used to display this Image.
29030
29635
  * Cropping takes place from the top-left of the Image and can be modified in real-time by providing an updated rectangle object.
29636
+ * The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
29637
+ * Please note that the rectangle object given is not duplicated by this method, but rather the Image uses a reference to the rectangle.
29638
+ * Keep this in mind if assigning a rectangle in a for-loop, or when cleaning up for garbage collection.
29031
29639
  *
29032
29640
  * @method Phaser.Image#crop
29033
29641
  * @memberof Phaser.Image
29034
- * @param {Phaser.Rectangle} rect - The Rectangle to crop the Image to. Pass null or no parameters to clear a previously set crop rectangle.
29642
+ * @param {Phaser.Rectangle|object} rect - The Rectangle to crop the Image to. Pass null or no parameters to clear a previously set crop rectangle.
29035
29643
  */
29036
29644
  Phaser.Image.prototype.crop = function(rect) {
29037
29645
 
@@ -31796,6 +32404,12 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
31796
32404
  */
31797
32405
  this._onUpFrameID = null;
31798
32406
 
32407
+ /**
32408
+ * @property {boolean} onOverMouseOnly - If true then onOver events (such as onOverSound) will only be triggered if the Pointer object causing them was the Mouse Pointer.
32409
+ * @default
32410
+ */
32411
+ this.onOverMouseOnly = false;
32412
+
31799
32413
  /**
31800
32414
  * @property {Phaser.Sound} onOverSound - The Sound to be played when this Buttons Over state is activated.
31801
32415
  * @default
@@ -32157,6 +32771,11 @@ Phaser.Button.prototype.onInputOverHandler = function (sprite, pointer) {
32157
32771
  this.setState(1);
32158
32772
  }
32159
32773
 
32774
+ if (this.onOverMouseOnly && !pointer.isMouse)
32775
+ {
32776
+ return;
32777
+ }
32778
+
32160
32779
  if (this.onOverSound)
32161
32780
  {
32162
32781
  this.onOverSound.play(this.onOverSoundMarker);
@@ -32166,6 +32785,7 @@ Phaser.Button.prototype.onInputOverHandler = function (sprite, pointer) {
32166
32785
  {
32167
32786
  this.onInputOver.dispatch(this, pointer);
32168
32787
  }
32788
+
32169
32789
  };
32170
32790
 
32171
32791
  /**
@@ -32545,10 +33165,119 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) {
32545
33165
 
32546
33166
  };
32547
33167
 
33168
+ /*
33169
+ * Draws a single {Phaser.Polygon} triangle from a {Phaser.Point} array
33170
+ *
33171
+ * @method Phaser.Graphics.prototype.drawTriangle
33172
+ * @param {Array<Phaser.Point>} points - An array of Phaser.Points that make up the three vertices of this triangle
33173
+ * @param {boolean} [cull=false] - Should we check if the triangle is back-facing
33174
+ */
33175
+ Phaser.Graphics.prototype.drawTriangle = function(points, cull) {
33176
+
33177
+ if (typeof cull === 'undefined') { cull = false; }
33178
+
33179
+ var triangle = new Phaser.Polygon(points);
33180
+
33181
+ if (cull)
33182
+ {
33183
+ var cameraToFace = new Phaser.Point(this.game.camera.x - points[0].x, this.game.camera.y - points[0].y);
33184
+ var ab = new Phaser.Point(points[1].x - points[0].x, points[1].y - points[0].y);
33185
+ var cb = new Phaser.Point(points[1].x - points[2].x, points[1].y - points[2].y);
33186
+ var faceNormal = cb.cross(ab);
33187
+
33188
+ if (cameraToFace.dot(faceNormal) > 0)
33189
+ {
33190
+ this.drawPolygon(triangle);
33191
+ }
33192
+ }
33193
+ else
33194
+ {
33195
+ this.drawPolygon(triangle);
33196
+ }
33197
+
33198
+ };
33199
+
33200
+ /*
33201
+ * Draws {Phaser.Polygon} triangles
33202
+ *
33203
+ * @method Phaser.Graphics.prototype.drawTriangles
33204
+ * @param {Array<Phaser.Point>|Array<number>} vertices - An array of Phaser.Points or numbers that make up the vertices of the triangles
33205
+ * @param {Array<number>} {indices=null} - An array of numbers that describe what order to draw the vertices in
33206
+ * @param {boolean} [cull=false] - Should we check if the triangle is back-facing
33207
+ */
33208
+ Phaser.Graphics.prototype.drawTriangles = function(vertices, indices, cull) {
33209
+
33210
+ if (typeof cull === 'undefined') { cull = false; }
33211
+
33212
+ var point1 = new Phaser.Point();
33213
+ var point2 = new Phaser.Point();
33214
+ var point3 = new Phaser.Point();
33215
+ var points = [];
33216
+ var i;
33217
+
33218
+ if (!indices)
33219
+ {
33220
+ if (vertices[0] instanceof Phaser.Point)
33221
+ {
33222
+ for (i = 0; i < vertices.length / 3; i++)
33223
+ {
33224
+ this.drawTriangle([vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]], cull);
33225
+ }
33226
+ }
33227
+ else
33228
+ {
33229
+ for (i = 0; i < vertices.length / 6; i++)
33230
+ {
33231
+ point1.x = vertices[i * 6 + 0];
33232
+ point1.y = vertices[i * 6 + 1];
33233
+ point2.x = vertices[i * 6 + 2];
33234
+ point2.y = vertices[i * 6 + 3];
33235
+ point3.x = vertices[i * 6 + 4];
33236
+ point3.y = vertices[i * 6 + 5];
33237
+ this.drawTriangle([point1, point2, point3], cull);
33238
+ }
33239
+ }
33240
+ }
33241
+ else
33242
+ {
33243
+ if (vertices[0] instanceof Phaser.Point)
33244
+ {
33245
+ for (i = 0; i < indices.length /3; i++)
33246
+ {
33247
+ points.push(vertices[indices[i * 3 ]]);
33248
+ points.push(vertices[indices[i * 3 + 1]]);
33249
+ points.push(vertices[indices[i * 3 + 2]]);
33250
+
33251
+ if (points.length === 3)
33252
+ {
33253
+ this.drawTriangle(points, cull);
33254
+ points = [];
33255
+ }
33256
+ }
33257
+ }
33258
+ else
33259
+ {
33260
+ for (i = 0; i < indices.length; i++)
33261
+ {
33262
+ point1.x = vertices[indices[i] * 2];
33263
+ point1.y = vertices[indices[i] * 2 + 1];
33264
+ points.push(point1.copyTo({}));
33265
+
33266
+ if (points.length === 3)
33267
+ {
33268
+ this.drawTriangle(points, cull);
33269
+ points = [];
33270
+ }
33271
+ }
33272
+ }
33273
+ }
33274
+ };
33275
+
32548
33276
  /**
32549
33277
  * Indicates the rotation of the Graphics, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
32550
33278
  * Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
32551
33279
  * If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
33280
+ *
32552
33281
  * @name Phaser.Graphics#angle
32553
33282
  * @property {number} angle - Gets or sets the angle of rotation in degrees.
32554
33283
  */
@@ -32623,8 +33352,13 @@ Object.defineProperty(Phaser.Graphics.prototype, "destroyPhase", {
32623
33352
  * @param {string} key - Internal Phaser reference key for the render texture.
32624
33353
  * @param {number} [width=100] - The width of the render texture.
32625
33354
  * @param {number} [height=100] - The height of the render texture.
33355
+ * @param {string} [key=''] - The key of the RenderTexture in the Cache, if stored there.
33356
+ * @param {number} [scaleMode=Phaser.scaleModes.DEFAULT] - One of the Phaser.scaleModes consts.
32626
33357
  */
32627
- Phaser.RenderTexture = function (game, width, height, key) {
33358
+ Phaser.RenderTexture = function (game, width, height, key, scaleMode) {
33359
+
33360
+ if (typeof key === 'undefined') { key = ''; }
33361
+ if (typeof scaleMode === 'undefined') { scaleMode = Phaser.scaleModes.DEFAULT; }
32628
33362
 
32629
33363
  /**
32630
33364
  * @property {Phaser.Game} game - A reference to the currently running game.
@@ -32647,7 +33381,7 @@ Phaser.RenderTexture = function (game, width, height, key) {
32647
33381
  */
32648
33382
  this._temp = new Phaser.Point();
32649
33383
 
32650
- PIXI.RenderTexture.call(this, width, height);
33384
+ PIXI.RenderTexture.call(this, width, height, scaleMode);
32651
33385
 
32652
33386
  };
32653
33387
 
@@ -33039,41 +33773,6 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac
33039
33773
 
33040
33774
  };
33041
33775
 
33042
- /**
33043
- * Over rides the default PIXI.RenderTexture resize event as we need our baseTexture resized as well.
33044
- *
33045
- * @method Phaser.RetroFont#resize
33046
- * @memberof Phaser.RetroFont
33047
- */
33048
- Phaser.RetroFont.prototype.resize = function (width, height) {
33049
-
33050
- this.width = width;
33051
- this.height = height;
33052
-
33053
- this.frame.width = this.width;
33054
- this.frame.height = this.height;
33055
-
33056
- this.baseTexture.width = this.width;
33057
- this.baseTexture.height = this.height;
33058
-
33059
- if (this.renderer.type === PIXI.WEBGL_RENDERER)
33060
- {
33061
- this.projection.x = this.width / 2;
33062
- this.projection.y = -this.height / 2;
33063
-
33064
- var gl = this.renderer.gl;
33065
- gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTextures[gl.id]);
33066
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
33067
- }
33068
- else
33069
- {
33070
- this.textureBuffer.resize(this.width, this.height);
33071
- }
33072
-
33073
- PIXI.Texture.frameUpdates.push(this);
33074
-
33075
- };
33076
-
33077
33776
  /**
33078
33777
  * Updates the BitmapData of the Sprite with the text
33079
33778
  *
@@ -33085,21 +33784,21 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
33085
33784
  var cx = 0;
33086
33785
  var cy = 0;
33087
33786
 
33787
+ this.clear();
33788
+
33088
33789
  if (this.multiLine)
33089
33790
  {
33090
33791
  var lines = this._text.split("\n");
33091
33792
 
33092
33793
  if (this.fixedWidth > 0)
33093
33794
  {
33094
- this.resize(this.fixedWidth, (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY);
33795
+ this.resize(this.fixedWidth, (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY, true);
33095
33796
  }
33096
33797
  else
33097
33798
  {
33098
- this.resize(this.getLongestLine() * (this.characterWidth + this.customSpacingX), (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY);
33799
+ this.resize(this.getLongestLine() * (this.characterWidth + this.customSpacingX), (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY, true);
33099
33800
  }
33100
33801
 
33101
- this.textureBuffer.clear();
33102
-
33103
33802
  // Loop through each line of text
33104
33803
  for (var i = 0; i < lines.length; i++)
33105
33804
  {
@@ -33135,15 +33834,13 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
33135
33834
  {
33136
33835
  if (this.fixedWidth > 0)
33137
33836
  {
33138
- this.resize(this.fixedWidth, this.characterHeight);
33837
+ this.resize(this.fixedWidth, this.characterHeight, true);
33139
33838
  }
33140
33839
  else
33141
33840
  {
33142
- this.resize(this._text.length * (this.characterWidth + this.customSpacingX), this.characterHeight);
33841
+ this.resize(this._text.length * (this.characterWidth + this.customSpacingX), this.characterHeight, true);
33143
33842
  }
33144
33843
 
33145
- this.textureBuffer.clear();
33146
-
33147
33844
  switch (this.align)
33148
33845
  {
33149
33846
  case Phaser.RetroFont.ALIGN_LEFT:
@@ -33160,6 +33857,8 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
33160
33857
  break;
33161
33858
  }
33162
33859
 
33860
+ this.textureBuffer.clear();
33861
+
33163
33862
  this.pasteLine(this._text, cx, 0, this.customSpacingX);
33164
33863
  }
33165
33864
 
@@ -34371,10 +35070,6 @@ Phaser.Device.prototype = {
34371
35070
  {
34372
35071
  this.safari = true;
34373
35072
  }
34374
- else if (/Silk/.test(ua))
34375
- {
34376
- this.silk = true;
34377
- }
34378
35073
  else if (/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(ua))
34379
35074
  {
34380
35075
  this.ie = true;
@@ -34383,6 +35078,12 @@ Phaser.Device.prototype = {
34383
35078
  this.ieVersion = parseInt(RegExp.$3, 10);
34384
35079
  }
34385
35080
 
35081
+ //Silk gets its own if clause because its ua also contains 'Safari'
35082
+ if (/Silk/.test(ua))
35083
+ {
35084
+ this.silk = true;
35085
+ }
35086
+
34386
35087
  // WebApp mode in iOS
34387
35088
  if (navigator['standalone'])
34388
35089
  {
@@ -35235,7 +35936,6 @@ Phaser.Math = {
35235
35936
  * @param {number} a2
35236
35937
  * @param {boolean} radians - True if angle sizes are expressed in radians.
35237
35938
  * @return {number}
35238
- */
35239
35939
  nearestAngleBetween: function (a1, a2, radians) {
35240
35940
 
35241
35941
  if (typeof radians === "undefined") { radians = true; }
@@ -35257,6 +35957,7 @@ Phaser.Math = {
35257
35957
  return a2 - a1;
35258
35958
 
35259
35959
  },
35960
+ */
35260
35961
 
35261
35962
  /**
35262
35963
  * Interpolate across the shortest arc between two angles.
@@ -35267,7 +35968,6 @@ Phaser.Math = {
35267
35968
  * @param {boolean} radians - True if angle sizes are expressed in radians.
35268
35969
  * @param {Description} ease - Description.
35269
35970
  * @return {number}
35270
- */
35271
35971
  interpolateAngles: function (a1, a2, weight, radians, ease) {
35272
35972
 
35273
35973
  if (typeof radians === "undefined") { radians = true; }
@@ -35279,6 +35979,7 @@ Phaser.Math = {
35279
35979
  return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight);
35280
35980
 
35281
35981
  },
35982
+ */
35282
35983
 
35283
35984
  /**
35284
35985
  * Generate a random bool result based on the chance value.
@@ -36127,6 +36828,34 @@ Phaser.Math = {
36127
36828
 
36128
36829
  },
36129
36830
 
36831
+ /**
36832
+ * Work out what percentage value a is of value b using the given base.
36833
+ *
36834
+ * @method Phaser.Math#percent
36835
+ * @param {number} a - The value to work out the percentage for.
36836
+ * @param {number} b - The value you wish to get the percentage of.
36837
+ * @param {number} [base=0] - The base value.
36838
+ * @return {number} The percentage a is of b, between 0 and 1.
36839
+ */
36840
+ percent: function (a, b, base) {
36841
+
36842
+ if (typeof base === 'undefined') { base = 0; }
36843
+
36844
+ if (a > b || base > b)
36845
+ {
36846
+ return 1;
36847
+ }
36848
+ else if (a < base || base > a)
36849
+ {
36850
+ return 0;
36851
+ }
36852
+ else
36853
+ {
36854
+ return (a - base) / b;
36855
+ }
36856
+
36857
+ },
36858
+
36130
36859
  /**
36131
36860
  * Convert degrees to radians.
36132
36861
  *
@@ -36341,7 +37070,7 @@ Phaser.RandomDataGenerator.prototype = {
36341
37070
  */
36342
37071
  integerInRange: function (min, max) {
36343
37072
 
36344
- return Math.floor(this.realInRange(0, max - min + 1)) + min;
37073
+ return Math.floor(this.realInRange(0, max - min + 1) + min);
36345
37074
 
36346
37075
  },
36347
37076
 
@@ -36732,37 +37461,46 @@ Phaser.QuadTree.prototype = {
36732
37461
  },
36733
37462
 
36734
37463
  /**
36735
- * Return all objects that could collide with the given Sprite.
37464
+ * Return all objects that could collide with the given Sprite or Rectangle.
36736
37465
  *
36737
37466
  * @method Phaser.QuadTree#retrieve
36738
- * @param {Phaser.Sprite} sprite - The sprite to check against.
37467
+ * @param {Phaser.Sprite|Phaser.Rectangle} source - The source object to check the QuadTree against. Either a Sprite or Rectangle.
36739
37468
  * @return {array} - Array with all detected objects.
36740
37469
  */
36741
- retrieve: function (sprite) {
37470
+ retrieve: function (source) {
36742
37471
 
36743
- if (!sprite.body)
37472
+ if (source instanceof Phaser.Rectangle)
36744
37473
  {
36745
- return this._empty;
37474
+ var returnObjects = this.objects;
37475
+
37476
+ var index = this.getIndex(source);
36746
37477
  }
37478
+ else
37479
+ {
37480
+ if (!source.body)
37481
+ {
37482
+ return this._empty;
37483
+ }
36747
37484
 
36748
- var returnObjects = this.objects;
37485
+ var returnObjects = this.objects;
36749
37486
 
36750
- var index = this.getIndex(sprite.body);
37487
+ var index = this.getIndex(source.body);
37488
+ }
36751
37489
 
36752
37490
  if (this.nodes[0])
36753
37491
  {
36754
37492
  // If rect fits into a subnode ..
36755
37493
  if (index !== -1)
36756
37494
  {
36757
- returnObjects = returnObjects.concat(this.nodes[index].retrieve(sprite));
37495
+ returnObjects = returnObjects.concat(this.nodes[index].retrieve(source));
36758
37496
  }
36759
37497
  else
36760
37498
  {
36761
37499
  // If rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
36762
- returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite));
36763
- returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite));
36764
- returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite));
36765
- returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite));
37500
+ returnObjects = returnObjects.concat(this.nodes[0].retrieve(source));
37501
+ returnObjects = returnObjects.concat(this.nodes[1].retrieve(source));
37502
+ returnObjects = returnObjects.concat(this.nodes[2].retrieve(source));
37503
+ returnObjects = returnObjects.concat(this.nodes[3].retrieve(source));
36766
37504
  }
36767
37505
  }
36768
37506
 
@@ -37457,6 +38195,30 @@ Phaser.Tween.prototype = {
37457
38195
 
37458
38196
  },
37459
38197
 
38198
+ /**
38199
+ * Configure a Reverse Tween
38200
+ *
38201
+ * @method Phaser.Tween#from
38202
+ * @param {object} properties - Properties you want to tween from.
38203
+ * @param {number} [duration=1000] - Duration of this tween in ms.
38204
+ * @param {function} [ease=null] - Easing function. If not set it will default to Phaser.Easing.Linear.None.
38205
+ * @param {boolean} [autoStart=false] - Whether this tween will start automatically or not.
38206
+ * @param {number} [delay=0] - Delay before this tween will start, defaults to 0 (no delay). Value given is in ms.
38207
+ * @param {number} [repeat=0] - Should the tween automatically restart once complete? If you want it to run forever set as Number.MAX_VALUE. This ignores any chained tweens.
38208
+ * @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself and play backwards automatically. A yoyo'd tween doesn't fire the Tween.onComplete event, so listen for Tween.onLoop instead.
38209
+ * @return {Phaser.Tween} This Tween object.
38210
+ */
38211
+ from: function(properties, duration, ease, autoStart, delay, repeat, yoyo) {
38212
+ var _cache = {};
38213
+ for(var prop in properties) {
38214
+ if (properties.hasOwnProperty(prop)) {
38215
+ _cache[prop] = this._object[prop];
38216
+ this._object[prop] = properties[prop];
38217
+ }
38218
+ }
38219
+ this.to(_cache, duration, ease, autoStart, delay, repeat, yoyo);
38220
+ },
38221
+
37460
38222
  /**
37461
38223
  * Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
37462
38224
  *
@@ -37916,12 +38678,16 @@ Phaser.Tween.prototype = {
37916
38678
  var tmp = this._valuesStartRepeat[property];
37917
38679
  this._valuesStartRepeat[property] = this._valuesEnd[property];
37918
38680
  this._valuesEnd[property] = tmp;
37919
- this._reversed = !this._reversed;
37920
38681
  }
37921
38682
 
37922
38683
  this._valuesStart[property] = this._valuesStartRepeat[property];
37923
38684
  }
37924
38685
 
38686
+ if (this._yoyo)
38687
+ {
38688
+ this._reversed = !this._reversed;
38689
+ }
38690
+
37925
38691
  this._startTime = time + this._delayTime;
37926
38692
 
37927
38693
  this.onLoop.dispatch(this._object);
@@ -39383,6 +40149,13 @@ Phaser.Timer.prototype = {
39383
40149
  */
39384
40150
  pause: function () {
39385
40151
 
40152
+ if (!this.running)
40153
+ {
40154
+ return;
40155
+ }
40156
+
40157
+ this._codePaused = true;
40158
+
39386
40159
  if (this.paused)
39387
40160
  {
39388
40161
  return;
@@ -39391,7 +40164,6 @@ Phaser.Timer.prototype = {
39391
40164
  this._pauseStarted = this.game.time.now;
39392
40165
 
39393
40166
  this.paused = true;
39394
- this._codePaused = true;
39395
40167
 
39396
40168
  },
39397
40169
 
@@ -39402,7 +40174,7 @@ Phaser.Timer.prototype = {
39402
40174
  */
39403
40175
  _pause: function () {
39404
40176
 
39405
- if (this.paused)
40177
+ if (this.paused || !this.running)
39406
40178
  {
39407
40179
  return;
39408
40180
  }
@@ -39462,8 +40234,9 @@ Phaser.Timer.prototype = {
39462
40234
  return;
39463
40235
  }
39464
40236
 
39465
- this._pauseTotal += this.game.time.pauseDuration;
39466
- this._now = this.game.time.now;
40237
+ var now = this.game.time.now;
40238
+ this._pauseTotal += now - this._now;
40239
+ this._now = now;
39467
40240
 
39468
40241
  this.adjustEvents(this._pauseStarted);
39469
40242
 
@@ -39776,7 +40549,7 @@ Phaser.AnimationManager.prototype = {
39776
40549
  */
39777
40550
  add: function (name, frames, frameRate, loop, useNumericIndex) {
39778
40551
 
39779
- if (this._frameData == null)
40552
+ if (this._frameData === null)
39780
40553
  {
39781
40554
  console.warn('No FrameData available for Phaser.Animation ' + name);
39782
40555
  return;
@@ -39801,7 +40574,7 @@ Phaser.AnimationManager.prototype = {
39801
40574
  }
39802
40575
 
39803
40576
  // Create the signals the AnimationManager will emit
39804
- if (this.sprite.events.onAnimationStart == null)
40577
+ if (this.sprite.events.onAnimationStart === null)
39805
40578
  {
39806
40579
  this.sprite.events.onAnimationStart = new Phaser.Signal();
39807
40580
  this.sprite.events.onAnimationComplete = new Phaser.Signal();
@@ -41630,6 +42403,23 @@ Phaser.Cache = function (game) {
41630
42403
  */
41631
42404
  this.onSoundUnlock = new Phaser.Signal();
41632
42405
 
42406
+ /**
42407
+ * @property {array} _cacheMap - Const to cache object look-up array.
42408
+ */
42409
+ this._cacheMap = [];
42410
+
42411
+ this._cacheMap[Phaser.Cache.CANVAS] = this._canvases;
42412
+ this._cacheMap[Phaser.Cache.IMAGE] = this._images;
42413
+ this._cacheMap[Phaser.Cache.TEXTURE] = this._textures;
42414
+ this._cacheMap[Phaser.Cache.SOUND] = this._sounds;
42415
+ this._cacheMap[Phaser.Cache.TEXT] = this._text;
42416
+ this._cacheMap[Phaser.Cache.PHYSICS] = this._physics;
42417
+ this._cacheMap[Phaser.Cache.TILEMAP] = this._tilemaps;
42418
+ this._cacheMap[Phaser.Cache.BINARY] = this._binary;
42419
+ this._cacheMap[Phaser.Cache.BITMAPDATA] = this._bitmapDatas;
42420
+ this._cacheMap[Phaser.Cache.BITMAPFONT] = this._bitmapFont;
42421
+ this._cacheMap[Phaser.Cache.JSON] = this._json;
42422
+
41633
42423
  };
41634
42424
 
41635
42425
  /**
@@ -42169,15 +42959,16 @@ Phaser.Cache.prototype = {
42169
42959
  },
42170
42960
 
42171
42961
  /**
42172
- * Checks if an image key exists.
42962
+ * Checks if a key for the given cache object type exists.
42173
42963
  *
42174
- * @method Phaser.Cache#checkImageKey
42964
+ * @method Phaser.Cache#checkKey
42965
+ * @param {number} type - The Cache type to check against. I.e. Phaser.Cache.CANVAS, Phaser.Cache.IMAGE, Phaser.Cache.JSON, etc.
42175
42966
  * @param {string} key - Asset key of the image to check is in the Cache.
42176
42967
  * @return {boolean} True if the key exists, otherwise false.
42177
42968
  */
42178
- checkImageKey: function (key) {
42969
+ checkKey: function (type, key) {
42179
42970
 
42180
- if (this._images[key])
42971
+ if (this._cacheMap[type][key])
42181
42972
  {
42182
42973
  return true;
42183
42974
  }
@@ -42186,6 +42977,149 @@ Phaser.Cache.prototype = {
42186
42977
 
42187
42978
  },
42188
42979
 
42980
+ /**
42981
+ * Checks if the given key exists in the Canvas Cache.
42982
+ *
42983
+ * @method Phaser.Cache#checkCanvasKey
42984
+ * @param {string} key - Asset key of the image to check is in the Cache.
42985
+ * @return {boolean} True if the key exists, otherwise false.
42986
+ */
42987
+ checkCanvasKey: function (key) {
42988
+
42989
+ return this.checkKey(Phaser.Cache.CANVAS, key);
42990
+
42991
+ },
42992
+
42993
+ /**
42994
+ * Checks if the given key exists in the Image Cache. Note that this also includes Texture Atlases, Sprite Sheets and Retro Fonts.
42995
+ *
42996
+ * @method Phaser.Cache#checkImageKey
42997
+ * @param {string} key - Asset key of the image to check is in the Cache.
42998
+ * @return {boolean} True if the key exists, otherwise false.
42999
+ */
43000
+ checkImageKey: function (key) {
43001
+
43002
+ return this.checkKey(Phaser.Cache.IMAGE, key);
43003
+
43004
+ },
43005
+
43006
+ /**
43007
+ * Checks if the given key exists in the Texture Cache.
43008
+ *
43009
+ * @method Phaser.Cache#checkTextureKey
43010
+ * @param {string} key - Asset key of the image to check is in the Cache.
43011
+ * @return {boolean} True if the key exists, otherwise false.
43012
+ */
43013
+ checkTextureKey: function (key) {
43014
+
43015
+ return this.checkKey(Phaser.Cache.TEXTURE, key);
43016
+
43017
+ },
43018
+
43019
+ /**
43020
+ * Checks if the given key exists in the Sound Cache.
43021
+ *
43022
+ * @method Phaser.Cache#checkSoundKey
43023
+ * @param {string} key - Asset key of the image to check is in the Cache.
43024
+ * @return {boolean} True if the key exists, otherwise false.
43025
+ */
43026
+ checkSoundKey: function (key) {
43027
+
43028
+ return this.checkKey(Phaser.Cache.SOUND, key);
43029
+
43030
+ },
43031
+
43032
+ /**
43033
+ * Checks if the given key exists in the Text Cache.
43034
+ *
43035
+ * @method Phaser.Cache#checkTextKey
43036
+ * @param {string} key - Asset key of the image to check is in the Cache.
43037
+ * @return {boolean} True if the key exists, otherwise false.
43038
+ */
43039
+ checkTextKey: function (key) {
43040
+
43041
+ return this.checkKey(Phaser.Cache.TEXT, key);
43042
+
43043
+ },
43044
+
43045
+ /**
43046
+ * Checks if the given key exists in the Physics Cache.
43047
+ *
43048
+ * @method Phaser.Cache#checkPhysicsKey
43049
+ * @param {string} key - Asset key of the image to check is in the Cache.
43050
+ * @return {boolean} True if the key exists, otherwise false.
43051
+ */
43052
+ checkPhysicsKey: function (key) {
43053
+
43054
+ return this.checkKey(Phaser.Cache.PHYSICS, key);
43055
+
43056
+ },
43057
+
43058
+ /**
43059
+ * Checks if the given key exists in the Tilemap Cache.
43060
+ *
43061
+ * @method Phaser.Cache#checkTilemapKey
43062
+ * @param {string} key - Asset key of the image to check is in the Cache.
43063
+ * @return {boolean} True if the key exists, otherwise false.
43064
+ */
43065
+ checkTilemapKey: function (key) {
43066
+
43067
+ return this.checkKey(Phaser.Cache.TILEMAP, key);
43068
+
43069
+ },
43070
+
43071
+ /**
43072
+ * Checks if the given key exists in the Binary Cache.
43073
+ *
43074
+ * @method Phaser.Cache#checkBinaryKey
43075
+ * @param {string} key - Asset key of the image to check is in the Cache.
43076
+ * @return {boolean} True if the key exists, otherwise false.
43077
+ */
43078
+ checkBinaryKey: function (key) {
43079
+
43080
+ return this.checkKey(Phaser.Cache.BINARY, key);
43081
+
43082
+ },
43083
+
43084
+ /**
43085
+ * Checks if the given key exists in the BitmapData Cache.
43086
+ *
43087
+ * @method Phaser.Cache#checkBitmapDataKey
43088
+ * @param {string} key - Asset key of the image to check is in the Cache.
43089
+ * @return {boolean} True if the key exists, otherwise false.
43090
+ */
43091
+ checkBitmapDataKey: function (key) {
43092
+
43093
+ return this.checkKey(Phaser.Cache.BITMAPDATA, key);
43094
+
43095
+ },
43096
+
43097
+ /**
43098
+ * Checks if the given key exists in the BitmapFont Cache.
43099
+ *
43100
+ * @method Phaser.Cache#checkBitmapFontKey
43101
+ * @param {string} key - Asset key of the image to check is in the Cache.
43102
+ * @return {boolean} True if the key exists, otherwise false.
43103
+ */
43104
+ checkBitmapFontKey: function (key) {
43105
+
43106
+ return this.checkKey(Phaser.Cache.BITMAPFONT, key);
43107
+
43108
+ },
43109
+
43110
+ /**
43111
+ * Checks if the given key exists in the JSON Cache.
43112
+ *
43113
+ * @method Phaser.Cache#checkJSONKey
43114
+ * @param {string} key - Asset key of the image to check is in the Cache.
43115
+ * @return {boolean} True if the key exists, otherwise false.
43116
+ */
43117
+ checkJSONKey: function (key) {
43118
+
43119
+ return this.checkKey(Phaser.Cache.JSON, key);
43120
+
43121
+ },
43122
+
42189
43123
  /**
42190
43124
  * Get image data by key.
42191
43125
  *
@@ -42908,6 +43842,7 @@ Phaser.Loader.prototype = {
42908
43842
  * You can set a Sprite to be a "preload" sprite by passing it to this method.
42909
43843
  * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
42910
43844
  * This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
43845
+ * Note: The Sprite should use a single image and not use a texture that is part of a Texture Atlas or Sprite Sheet.
42911
43846
  *
42912
43847
  * @method Phaser.Loader#setPreloadSprite
42913
43848
  * @param {Phaser.Sprite|Phaser.Image} sprite - The sprite or image that will be cropped during the load.
@@ -42938,7 +43873,8 @@ Phaser.Loader.prototype = {
42938
43873
 
42939
43874
  /**
42940
43875
  * Check whether asset exists with a specific key.
42941
- *
43876
+ * Use Phaser.Cache to access loaded assets, e.g. Phaser.Cache#checkImageKey
43877
+ *
42942
43878
  * @method Phaser.Loader#checkKeyExists
42943
43879
  * @param {string} type - The type asset you want to check.
42944
43880
  * @param {string} key - Key of the asset you want to check.
@@ -44764,7 +45700,7 @@ Phaser.Sound.prototype = {
44764
45700
  if (this.isPlaying === true && forceRestart === false && this.override === false)
44765
45701
  {
44766
45702
  // Use Restart instead
44767
- return;
45703
+ return this;
44768
45704
  }
44769
45705
 
44770
45706
  if (this.isPlaying && this.override)
@@ -44818,7 +45754,7 @@ Phaser.Sound.prototype = {
44818
45754
  else
44819
45755
  {
44820
45756
  console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist");
44821
- return;
45757
+ return this;
44822
45758
  }
44823
45759
  }
44824
45760
  else
@@ -44955,6 +45891,9 @@ Phaser.Sound.prototype = {
44955
45891
  }
44956
45892
  }
44957
45893
  }
45894
+
45895
+ return this;
45896
+
44958
45897
  },
44959
45898
 
44960
45899
  /**
@@ -45066,7 +46005,13 @@ Phaser.Sound.prototype = {
45066
46005
  }
45067
46006
  else
45068
46007
  {
45069
- this._sound.stop(0);
46008
+ try {
46009
+ this._sound.stop(0);
46010
+ }
46011
+ catch (e)
46012
+ {
46013
+ // Thanks Android 4.4
46014
+ }
45070
46015
  }
45071
46016
  }
45072
46017
  else if (this.usingAudioTag)
@@ -45243,6 +46188,8 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", {
45243
46188
  * Sound Manager constructor.
45244
46189
  * The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it.
45245
46190
  * Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files.
46191
+ * The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats.
46192
+ * There is a good guide to what's supported here: http://hpr.dogphilosophy.net/test/
45246
46193
  *
45247
46194
  * @class Phaser.SoundManager
45248
46195
  * @classdesc Phaser Sound Manager.
@@ -47315,41 +48262,60 @@ Phaser.Color = {
47315
48262
  },
47316
48263
 
47317
48264
  /**
47318
- * Return the component parts of a color as an Object with the properties alpha, red, green, blue
48265
+ * Return the component parts of a color as an Object with the properties alpha, red, green, blue.
47319
48266
  *
47320
48267
  * Alpha will only be set if it exist in the given color (0xAARRGGBB)
47321
48268
  *
47322
48269
  * @method Phaser.Color.getRGB
47323
48270
  * @static
47324
48271
  * @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
47325
- * @returns {object} An Object with properties: alpha, red, green, blue.
48272
+ * @returns {object} An Object with properties: alpha, red, green, blue (also r, g, b and a). Alpha will only be present if a color value > 16777215 was given.
47326
48273
  */
47327
48274
  getRGB: function (color) {
47328
48275
 
47329
- return {
47330
- alpha: color >>> 24,
47331
- red: color >> 16 & 0xFF,
47332
- green: color >> 8 & 0xFF,
47333
- blue: color & 0xFF
47334
- };
48276
+ if (color > 16777215)
48277
+ {
48278
+ // The color value has an alpha component
48279
+ return {
48280
+ alpha: color >>> 24,
48281
+ red: color >> 16 & 0xFF,
48282
+ green: color >> 8 & 0xFF,
48283
+ blue: color & 0xFF,
48284
+ a: color >>> 24,
48285
+ r: color >> 16 & 0xFF,
48286
+ g: color >> 8 & 0xFF,
48287
+ b: color & 0xFF
48288
+ };
48289
+ }
48290
+ else
48291
+ {
48292
+ return {
48293
+ alpha: 255,
48294
+ red: color >> 16 & 0xFF,
48295
+ green: color >> 8 & 0xFF,
48296
+ blue: color & 0xFF,
48297
+ a: 255,
48298
+ r: color >> 16 & 0xFF,
48299
+ g: color >> 8 & 0xFF,
48300
+ b: color & 0xFF
48301
+ };
48302
+ }
47335
48303
 
47336
48304
  },
47337
48305
 
47338
48306
  /**
47339
48307
  * Returns a CSS friendly string value from the given color.
48308
+ *
47340
48309
  * @method Phaser.Color.getWebRGB
47341
48310
  * @static
47342
- * @param {number} color
47343
- * @returns {string}A string in the format: 'rgba(r,g,b,a)'
48311
+ * @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
48312
+ * @returns {string} A string in the format: 'rgba(r,g,b,a)'
47344
48313
  */
47345
48314
  getWebRGB: function (color) {
47346
48315
 
47347
- var alpha = (color >>> 24) / 255;
47348
- var red = color >> 16 & 0xFF;
47349
- var green = color >> 8 & 0xFF;
47350
- var blue = color & 0xFF;
48316
+ var rgb = Phaser.Color.getRGB(color);
47351
48317
 
47352
- return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')';
48318
+ return 'rgba(' + rgb.r.toString() + ',' + rgb.g.toString() + ',' + rgb.b.toString() + ',' + rgb.a.toString() + ')';
47353
48319
 
47354
48320
  },
47355
48321
 
@@ -49105,6 +50071,53 @@ Phaser.Physics.Arcade.prototype = {
49105
50071
 
49106
50072
  },
49107
50073
 
50074
+ /**
50075
+ * Given a Group and a Pointer this will check to see which Group children overlap with the Pointer coordinates.
50076
+ * Each child will be sent to the given callback for further processing.
50077
+ * Note that the children are not checked for depth order, but simply if they overlap the Pointer or not.
50078
+ *
50079
+ * @method Phaser.Physics.Arcade#getObjectsUnderPointer
50080
+ * @param {Phaser.Pointer} pointer - The Pointer to check.
50081
+ * @param {Phaser.Group} group - The Group to check.
50082
+ * @param {function} [callback] - A callback function that is called if the object overlaps with the Pointer. The callback will be sent two parameters: the Pointer and the Object that overlapped with it.
50083
+ * @param {object} [callbackContext] - The context in which to run the callback.
50084
+ * @return {array} An array of the Sprites from the Group that overlapped the Pointer coordinates.
50085
+ */
50086
+ getObjectsUnderPointer: function (pointer, group, callback, callbackContext) {
50087
+
50088
+ if (group.length === 0 || !pointer.exists)
50089
+ {
50090
+ return;
50091
+ }
50092
+
50093
+ this.quadTree.clear();
50094
+
50095
+ this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
50096
+
50097
+ this.quadTree.populate(group);
50098
+
50099
+ var rect = new Phaser.Rectangle(pointer.x, pointer.y, 1, 1);
50100
+ var output = [];
50101
+
50102
+ this._potentials = this.quadTree.retrieve(rect);
50103
+
50104
+ for (var i = 0, len = this._potentials.length; i < len; i++)
50105
+ {
50106
+ if (this._potentials[i].hitTest(pointer.x, pointer.y))
50107
+ {
50108
+ if (callback)
50109
+ {
50110
+ callback.call(callbackContext, pointer, this._potentials[i].sprite);
50111
+ }
50112
+
50113
+ output.push(this._potentials[i].sprite);
50114
+ }
50115
+ }
50116
+
50117
+ return output;
50118
+
50119
+ },
50120
+
49108
50121
  /**
49109
50122
  * Move the given display object towards the destination object at a steady velocity.
49110
50123
  * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds.
@@ -50701,12 +51714,12 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
50701
51714
 
50702
51715
  while (i < quantity)
50703
51716
  {
50704
- if (typeof keys === 'object')
51717
+ if (Array.isArray(keys))
50705
51718
  {
50706
51719
  rndKey = this.game.rnd.pick(keys);
50707
51720
  }
50708
51721
 
50709
- if (typeof frames === 'object')
51722
+ if (Array.isArray(frames))
50710
51723
  {
50711
51724
  rndFrame = this.game.rnd.pick(frames);
50712
51725
  }
@@ -51709,6 +52722,30 @@ Phaser.Tilemap.CSV = 0;
51709
52722
  */
51710
52723
  Phaser.Tilemap.TILED_JSON = 1;
51711
52724
 
52725
+ /**
52726
+ * @constant
52727
+ * @type {number}
52728
+ */
52729
+ Phaser.Tilemap.NORTH = 0;
52730
+
52731
+ /**
52732
+ * @constant
52733
+ * @type {number}
52734
+ */
52735
+ Phaser.Tilemap.EAST = 1;
52736
+
52737
+ /**
52738
+ * @constant
52739
+ * @type {number}
52740
+ */
52741
+ Phaser.Tilemap.SOUTH = 2;
52742
+
52743
+ /**
52744
+ * @constant
52745
+ * @type {number}
52746
+ */
52747
+ Phaser.Tilemap.WEST = 3;
52748
+
51712
52749
  Phaser.Tilemap.prototype = {
51713
52750
 
51714
52751
  /**
@@ -51928,7 +52965,7 @@ Phaser.Tilemap.prototype = {
51928
52965
 
51929
52966
  for (var property in this.objects[name][i].properties)
51930
52967
  {
51931
- group.set(sprite, property, this.objects[name][i].properties[property], false, false, 0);
52968
+ group.set(sprite, property, this.objects[name][i].properties[property], false, false, 0, true);
51932
52969
  }
51933
52970
  }
51934
52971
  }
@@ -52202,11 +53239,13 @@ Phaser.Tilemap.prototype = {
52202
53239
  * @param {number|array} indexes - Either a single tile index, or an array of tile IDs to be checked for collision.
52203
53240
  * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
52204
53241
  * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to operate on. If not given will default to this.currentLayer.
53242
+ * @param {boolean} [recalculate=true] - Recalculates the tile faces after the update.
52205
53243
  */
52206
- setCollision: function (indexes, collides, layer) {
53244
+ setCollision: function (indexes, collides, layer, recalculate) {
52207
53245
 
52208
53246
  if (typeof collides === 'undefined') { collides = true; }
52209
-
53247
+ if (typeof recalculate === 'undefined') { recalculate = true; }
53248
+
52210
53249
  layer = this.getLayer(layer);
52211
53250
 
52212
53251
  if (typeof indexes === 'number')
@@ -52221,8 +53260,11 @@ Phaser.Tilemap.prototype = {
52221
53260
  this.setCollisionByIndex(indexes[i], collides, layer, false);
52222
53261
  }
52223
53262
 
52224
- // Now re-calculate interesting faces
52225
- this.calculateFaces(layer);
53263
+ if (recalculate)
53264
+ {
53265
+ // Now re-calculate interesting faces
53266
+ this.calculateFaces(layer);
53267
+ }
52226
53268
  }
52227
53269
 
52228
53270
  },
@@ -52237,11 +53279,13 @@ Phaser.Tilemap.prototype = {
52237
53279
  * @param {number} stop - The last index of the tile to be set for collision.
52238
53280
  * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
52239
53281
  * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to operate on. If not given will default to this.currentLayer.
53282
+ * @param {boolean} [recalculate=true] - Recalculates the tile faces after the update.
52240
53283
  */
52241
- setCollisionBetween: function (start, stop, collides, layer) {
53284
+ setCollisionBetween: function (start, stop, collides, layer, recalculate) {
52242
53285
 
52243
53286
  if (typeof collides === 'undefined') { collides = true; }
52244
-
53287
+ if (typeof recalculate === 'undefined') { recalculate = true; }
53288
+
52245
53289
  layer = this.getLayer(layer);
52246
53290
 
52247
53291
  if (start > stop)
@@ -52254,8 +53298,11 @@ Phaser.Tilemap.prototype = {
52254
53298
  this.setCollisionByIndex(index, collides, layer, false);
52255
53299
  }
52256
53300
 
52257
- // Now re-calculate interesting faces
52258
- this.calculateFaces(layer);
53301
+ if (recalculate)
53302
+ {
53303
+ // Now re-calculate interesting faces
53304
+ this.calculateFaces(layer);
53305
+ }
52259
53306
 
52260
53307
  },
52261
53308
 
@@ -52267,11 +53314,13 @@ Phaser.Tilemap.prototype = {
52267
53314
  * @param {array} indexes - An array of the tile IDs to not be counted for collision.
52268
53315
  * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
52269
53316
  * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to operate on. If not given will default to this.currentLayer.
53317
+ * @param {boolean} [recalculate=true] - Recalculates the tile faces after the update.
52270
53318
  */
52271
- setCollisionByExclusion: function (indexes, collides, layer) {
53319
+ setCollisionByExclusion: function (indexes, collides, layer, recalculate) {
52272
53320
 
52273
53321
  if (typeof collides === 'undefined') { collides = true; }
52274
-
53322
+ if (typeof recalculate === 'undefined') { recalculate = true; }
53323
+
52275
53324
  layer = this.getLayer(layer);
52276
53325
 
52277
53326
  // Collide everything, except the IDs given in the indexes array
@@ -52283,8 +53332,11 @@ Phaser.Tilemap.prototype = {
52283
53332
  }
52284
53333
  }
52285
53334
 
52286
- // Now re-calculate interesting faces
52287
- this.calculateFaces(layer);
53335
+ if (recalculate)
53336
+ {
53337
+ // Now re-calculate interesting faces
53338
+ this.calculateFaces(layer);
53339
+ }
52288
53340
 
52289
53341
  },
52290
53342
 
@@ -52710,6 +53762,73 @@ Phaser.Tilemap.prototype = {
52710
53762
 
52711
53763
  },
52712
53764
 
53765
+ /**
53766
+ * Searches the entire map layer for the first tile matching the given index, then returns that Phaser.Tile object.
53767
+ * If no match is found it returns null.
53768
+ * The search starts from the top-left tile and continues horizontally until it hits the end of the row, then it drops down to the next column.
53769
+ * If the reverse boolean is true, it scans starting from the bottom-right corner travelling up to the top-left.
53770
+ *
53771
+ * @method Phaser.Tilemap#searchTileIndex
53772
+ * @param {number} index - The tile index value to search for.
53773
+ * @param {number} [skip=0] - The number of times to skip a matching tile before returning.
53774
+ * @param {number} [reverse=false] - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left.
53775
+ * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to get the tile from.
53776
+ * @return {Phaser.Tile} The first (or n skipped) tile with the matching index.
53777
+ */
53778
+ searchTileIndex: function (index, skip, reverse, layer) {
53779
+
53780
+ if (typeof skip === 'undefined') { skip = 0; }
53781
+ if (typeof reverse === 'undefined') { reverse = false; }
53782
+
53783
+ layer = this.getLayer(layer);
53784
+
53785
+ var c = 0;
53786
+
53787
+ if (reverse)
53788
+ {
53789
+ for (var y = this.layers[layer].height - 1; y >= 0; y--)
53790
+ {
53791
+ for (var x = this.layers[layer].width - 1; x >= 0; x--)
53792
+ {
53793
+ if (this.layers[layer].data[y][x].index === index)
53794
+ {
53795
+ if (c === skip)
53796
+ {
53797
+ return this.layers[layer].data[y][x];
53798
+ }
53799
+ else
53800
+ {
53801
+ c++;
53802
+ }
53803
+ }
53804
+ }
53805
+ }
53806
+ }
53807
+ else
53808
+ {
53809
+ for (var y = 0; y < this.layers[layer].height; y++)
53810
+ {
53811
+ for (var x = 0; x < this.layers[layer].width; x++)
53812
+ {
53813
+ if (this.layers[layer].data[y][x].index === index)
53814
+ {
53815
+ if (c === skip)
53816
+ {
53817
+ return this.layers[layer].data[y][x];
53818
+ }
53819
+ else
53820
+ {
53821
+ c++;
53822
+ }
53823
+ }
53824
+ }
53825
+ }
53826
+ }
53827
+
53828
+ return null;
53829
+
53830
+ },
53831
+
52713
53832
  /**
52714
53833
  * Gets a tile from the Tilemap Layer. The coordinates are given in tile values.
52715
53834
  *
@@ -52717,9 +53836,12 @@ Phaser.Tilemap.prototype = {
52717
53836
  * @param {number} x - X position to get the tile from (given in tile units, not pixels)
52718
53837
  * @param {number} y - Y position to get the tile from (given in tile units, not pixels)
52719
53838
  * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to get the tile from.
52720
- * @return {Phaser.Tile} The tile at the given coordinates.
53839
+ * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1.
53840
+ * @return {Phaser.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid.
52721
53841
  */
52722
- getTile: function (x, y, layer) {
53842
+ getTile: function (x, y, layer, nonNull) {
53843
+
53844
+ if (typeof nonNull === 'undefined') { nonNull = false; }
52723
53845
 
52724
53846
  layer = this.getLayer(layer);
52725
53847
 
@@ -52727,13 +53849,24 @@ Phaser.Tilemap.prototype = {
52727
53849
  {
52728
53850
  if (this.layers[layer].data[y][x].index === -1)
52729
53851
  {
52730
- return null;
53852
+ if (nonNull)
53853
+ {
53854
+ return this.layers[layer].data[y][x];
53855
+ }
53856
+ else
53857
+ {
53858
+ return null;
53859
+ }
52731
53860
  }
52732
53861
  else
52733
53862
  {
52734
53863
  return this.layers[layer].data[y][x];
52735
53864
  }
52736
53865
  }
53866
+ else
53867
+ {
53868
+ return null;
53869
+ }
52737
53870
 
52738
53871
  },
52739
53872
 
@@ -53165,6 +54298,29 @@ Phaser.Tilemap.prototype = {
53165
54298
 
53166
54299
  Phaser.Tilemap.prototype.constructor = Phaser.Tilemap;
53167
54300
 
54301
+ /**
54302
+ * @name Phaser.Tilemap#layer
54303
+ * @property {number|string|Phaser.TilemapLayer} layer - The current layer object.
54304
+ */
54305
+ Object.defineProperty(Phaser.Tilemap.prototype, "layer", {
54306
+
54307
+ get: function () {
54308
+
54309
+ return this.layers[this.currentLayer];
54310
+
54311
+ },
54312
+
54313
+ set: function (value) {
54314
+
54315
+ if (value !== this.currentLayer)
54316
+ {
54317
+ this.setLayer(value);
54318
+ }
54319
+
54320
+ }
54321
+
54322
+ });
54323
+
53168
54324
  /**
53169
54325
  * @author Richard Davey <rich@photonstorm.com>
53170
54326
  * @copyright 2014 Photon Storm Ltd.
@@ -54313,6 +55469,15 @@ Phaser.TilemapParser = {
54313
55469
  var objects = {};
54314
55470
  var collision = {};
54315
55471
 
55472
+ function slice (obj, fields) {
55473
+ var sliced = {};
55474
+ for (var k in fields) {
55475
+ var key = fields[k];
55476
+ sliced[key] = obj[key];
55477
+ }
55478
+ return sliced;
55479
+ }
55480
+
54316
55481
  for (var i = 0; i < json.layers.length; i++)
54317
55482
  {
54318
55483
  if (json.layers[i].type !== 'objectgroup')
@@ -54364,9 +55529,37 @@ Phaser.TilemapParser = {
54364
55529
  }
54365
55530
 
54366
55531
  collision[json.layers[i].name].push(object);
54367
-
54368
55532
  }
55533
+ // polygon
55534
+ else if (json.layers[i].objects[v].polygon)
55535
+ {
55536
+ var object = slice(json.layers[i].objects[v],
55537
+ ["name", "x", "y", "visible", "properties" ]);
55538
+
55539
+ // Parse the polygon into an array
55540
+ object.polygon = [];
55541
+ for (var p = 0; p < json.layers[i].objects[v].polygon.length; p++)
55542
+ {
55543
+ object.polygon.push([ json.layers[i].objects[v].polygon[p].x, json.layers[i].objects[v].polygon[p].y ]);
55544
+ }
55545
+ objects[json.layers[i].name].push(object);
54369
55546
 
55547
+ }
55548
+ // ellipse
55549
+ else if (json.layers[i].objects[v].ellipse)
55550
+ {
55551
+ var object = slice(json.layers[i].objects[v],
55552
+ ["name", "ellipse", "x", "y", "width", "height", "visible", "properties" ]);
55553
+ objects[json.layers[i].name].push(object);
55554
+ }
55555
+ // otherwise it's a rectangle
55556
+ else
55557
+ {
55558
+ var object = slice(json.layers[i].objects[v],
55559
+ ["name", "x", "y", "width", "height", "visible", "properties" ]);
55560
+ object.rectangle = true;
55561
+ objects[json.layers[i].name].push(object);
55562
+ }
54370
55563
  }
54371
55564
  }
54372
55565
 
@@ -73122,7 +74315,6 @@ Phaser.Physics.P2.prototype = {
73122
74315
  {
73123
74316
  output.push(body);
73124
74317
  }
73125
-
73126
74318
  }
73127
74319
 
73128
74320
  return output;
@@ -73147,7 +74339,7 @@ Phaser.Physics.P2.prototype = {
73147
74339
  map.layers[layer].bodies[i].destroy();
73148
74340
  }
73149
74341
 
73150
- map.layers[layer].bodies.length = [];
74342
+ map.layers[layer].bodies.length = 0;
73151
74343
 
73152
74344
  },
73153
74345
 
@@ -73186,7 +74378,7 @@ Phaser.Physics.P2.prototype = {
73186
74378
  {
73187
74379
  var tile = map.layers[layer].data[y][x];
73188
74380
 
73189
- if (tile && tile.collides)
74381
+ if (tile && tile.index > -1 && tile.collides)
73190
74382
  {
73191
74383
  if (optimize)
73192
74384
  {
@@ -75663,6 +76855,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
75663
76855
  /**
75664
76856
  * A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will leave the World.
75665
76857
  * Note that this only applies if your World has bounds! The response to the collision should be managed via CollisionMaterials.
76858
+ *
75666
76859
  * @name Phaser.Physics.P2.Body#collideWorldBounds
75667
76860
  * @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
75668
76861
  */
@@ -76342,7 +77535,7 @@ Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance,
76342
77535
 
76343
77536
  distance = world.pxm(distance);
76344
77537
 
76345
- p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce);
77538
+ p2.DistanceConstraint.call(this, bodyA, bodyB, distance, {maxForce: maxForce});
76346
77539
 
76347
77540
  };
76348
77541