phaser-rails 2.6.1.0 → 2.6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f813b82791c9acaa1bcd5d68dbbb8c89df159946
4
- data.tar.gz: b18c6dfaea15d2b468d11192b495e391ec833014
3
+ metadata.gz: 20941a8d4d4008a1646c5e31bffacd105f354375
4
+ data.tar.gz: af1055871cf47a5f67a65dd7ec6f16b05dc1de2a
5
5
  SHA512:
6
- metadata.gz: d3331dc565ab324c9ad04bbc3cce5bcb5b8ef5510d0c5499c59024d97f999a7085a443e3761de955b7e24374b6c7e94dd6bd7f0a8fe1afdad46c144f7d847c21
7
- data.tar.gz: 583e63d514a04fd718e53a755306bcc5460d82b319fdfc36eed8a39414d4411e01f558439c922c64b70e96f308d0542377e7a3f0ed9a0c8313c7ebaca7b65692
6
+ metadata.gz: 5fe638710ab190e43038824de000f89e80ad9254de317f1137a3a426d42ccba9144744f6a818255a788ed9e8bb6f0f164994535befef9150f957190a0b7c3a96
7
+ data.tar.gz: 25e57d4de22928fb387fb302628c55f349e9056cada076ca4d35363ba09eeec2032fef605628527edaa1b90efd5d24e58635b2d930111a21ab74e57509b1e416
@@ -1,5 +1,5 @@
1
1
  module Phaser
2
2
  module Rails
3
- VERSION = "2.6.1.0"
3
+ VERSION = "2.6.2.0"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Phaser - http://phaser.io
9
9
  *
10
- * v2.6.1 "Caemlyn" - Built: Mon Jul 11 2016 09:59:51
10
+ * v2.6.2 "Kore Springs" - Built: Fri Aug 26 2016 01:02:57
11
11
  *
12
12
  * By Richard Davey http://www.photonstorm.com @photonstorm
13
13
  *
@@ -13784,7 +13784,7 @@ PIXI.defaultRenderOptions = {
13784
13784
  * @class PIXI.DisplayObject
13785
13785
  * @constructor
13786
13786
  */
13787
- PIXI.DisplayObject = function() {
13787
+ PIXI.DisplayObject = function () {
13788
13788
 
13789
13789
  /**
13790
13790
  * The coordinates, in pixels, of this DisplayObject, relative to its parent container.
@@ -13885,15 +13885,6 @@ PIXI.DisplayObject = function() {
13885
13885
  */
13886
13886
  this.parent = null;
13887
13887
 
13888
- /**
13889
- * The stage that this DisplayObject is connected to.
13890
- *
13891
- * @property {PIXI.Stage} stage
13892
- * @default
13893
- * @readOnly
13894
- */
13895
- this.stage = null;
13896
-
13897
13888
  /**
13898
13889
  * The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
13899
13890
  * This value is the calculated total, based on the alpha values of all parents of this DisplayObjects
@@ -13995,7 +13986,7 @@ PIXI.DisplayObject = function() {
13995
13986
  * @property {PIXI.Rectangle} _bounds - The cached bounds of this object.
13996
13987
  * @private
13997
13988
  */
13998
- this._bounds = new PIXI.Rectangle(0, 0, 1, 1);
13989
+ this._bounds = new PIXI.Rectangle(0, 0, 0, 0);
13999
13990
 
14000
13991
  /**
14001
13992
  * @property {PIXI.Rectangle} _currentBounds - The most recently calculated bounds of this object.
@@ -14030,8 +14021,7 @@ PIXI.DisplayObject.prototype = {
14030
14021
  /**
14031
14022
  * Destroy this DisplayObject.
14032
14023
  *
14033
- * Removes any cached sprites, sets renderable flag to false, and nulls references to the Stage, filters,
14034
- * bounds and mask.
14024
+ * Removes any cached sprites, sets renderable flag to false, and nulls filters, bounds and mask.
14035
14025
  *
14036
14026
  * Also iteratively calls `destroy` on any children.
14037
14027
  *
@@ -14053,7 +14043,6 @@ PIXI.DisplayObject.prototype = {
14053
14043
 
14054
14044
  this.hitArea = null;
14055
14045
  this.parent = null;
14056
- this.stage = null;
14057
14046
  this.worldTransform = null;
14058
14047
  this.filterArea = null;
14059
14048
  this.renderable = false;
@@ -14082,7 +14071,7 @@ PIXI.DisplayObject.prototype = {
14082
14071
  * the new, updated, worldTransform property, along with the parent transform used.
14083
14072
  *
14084
14073
  * @method PIXI.DisplayObject#updateTransform
14085
- * @param {PIXI.DisplayObject} [parent] - Optional parent to calculate this DisplayObjects transform from.
14074
+ * @param {PIXI.DisplayObjectContainer} [parent] - Optional parent to calculate this DisplayObjects transform from.
14086
14075
  * @return {PIXI.DisplayObject} - A reference to this DisplayObject.
14087
14076
  */
14088
14077
  updateTransform: function (parent) {
@@ -14180,21 +14169,6 @@ PIXI.DisplayObject.prototype = {
14180
14169
 
14181
14170
  },
14182
14171
 
14183
- /**
14184
- * Sets the root Stage object that this DisplayObject is connected to.
14185
- *
14186
- * @method PIXI.DisplayObject#setStageReference
14187
- * @param {Phaser.Stage} stage - The stage that the object will have as its current stage reference
14188
- * @return {PIXI.DisplayObject} - A reference to this DisplayObject.
14189
- */
14190
- setStageReference: function (stage)
14191
- {
14192
- this.stage = stage;
14193
-
14194
- return this;
14195
-
14196
- },
14197
-
14198
14172
  /**
14199
14173
  * To be overridden by classes that require it.
14200
14174
  *
@@ -14439,16 +14413,24 @@ Object.defineProperties(PIXI.DisplayObject.prototype, {
14439
14413
  {
14440
14414
  var item = this.parent;
14441
14415
 
14442
- do
14416
+ if (!item)
14417
+ {
14418
+ return this.visible;
14419
+ }
14420
+ else
14443
14421
  {
14444
- if (!item.visible)
14422
+ do
14445
14423
  {
14446
- return false;
14424
+ if (!item.visible)
14425
+ {
14426
+ return false;
14427
+ }
14428
+
14429
+ item = item.parent;
14447
14430
  }
14431
+ while (item);
14448
14432
 
14449
- item = item.parent;
14450
14433
  }
14451
- while (item);
14452
14434
 
14453
14435
  return true;
14454
14436
  }
@@ -14604,8 +14586,8 @@ Object.defineProperties(PIXI.DisplayObject.prototype, {
14604
14586
  * @extends DisplayObject
14605
14587
  * @constructor
14606
14588
  */
14607
- PIXI.DisplayObjectContainer = function()
14608
- {
14589
+ PIXI.DisplayObjectContainer = function () {
14590
+
14609
14591
  PIXI.DisplayObject.call(this);
14610
14592
 
14611
14593
  /**
@@ -14630,69 +14612,9 @@ PIXI.DisplayObjectContainer = function()
14630
14612
 
14631
14613
  };
14632
14614
 
14633
- // constructor
14634
14615
  PIXI.DisplayObjectContainer.prototype = Object.create( PIXI.DisplayObject.prototype );
14635
14616
  PIXI.DisplayObjectContainer.prototype.constructor = PIXI.DisplayObjectContainer;
14636
14617
 
14637
- /**
14638
- * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
14639
- *
14640
- * @property width
14641
- * @type Number
14642
- */
14643
- Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
14644
-
14645
- get: function() {
14646
- return this.scale.x * this.getLocalBounds().width;
14647
- },
14648
-
14649
- set: function(value) {
14650
-
14651
- var width = this.getLocalBounds().width;
14652
-
14653
- if (width !== 0)
14654
- {
14655
- this.scale.x = value / width;
14656
- }
14657
- else
14658
- {
14659
- this.scale.x = 1;
14660
- }
14661
-
14662
- this._width = value;
14663
- }
14664
- });
14665
-
14666
- /**
14667
- * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
14668
- *
14669
- * @property height
14670
- * @type Number
14671
- */
14672
- Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
14673
-
14674
- get: function() {
14675
- return this.scale.y * this.getLocalBounds().height;
14676
- },
14677
-
14678
- set: function(value) {
14679
-
14680
- var height = this.getLocalBounds().height;
14681
-
14682
- if (height !== 0)
14683
- {
14684
- this.scale.y = value / height;
14685
- }
14686
- else
14687
- {
14688
- this.scale.y = 1;
14689
- }
14690
-
14691
- this._height = value;
14692
- }
14693
-
14694
- });
14695
-
14696
14618
  /**
14697
14619
  * Adds a child to the container.
14698
14620
  *
@@ -14700,9 +14622,10 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
14700
14622
  * @param child {DisplayObject} The DisplayObject to add to the container
14701
14623
  * @return {DisplayObject} The child that was added.
14702
14624
  */
14703
- PIXI.DisplayObjectContainer.prototype.addChild = function(child)
14704
- {
14625
+ PIXI.DisplayObjectContainer.prototype.addChild = function (child) {
14626
+
14705
14627
  return this.addChildAt(child, this.children.length);
14628
+
14706
14629
  };
14707
14630
 
14708
14631
  /**
@@ -14713,11 +14636,11 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
14713
14636
  * @param index {Number} The index to place the child in
14714
14637
  * @return {DisplayObject} The child that was added.
14715
14638
  */
14716
- PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
14717
- {
14718
- if(index >= 0 && index <= this.children.length)
14639
+ PIXI.DisplayObjectContainer.prototype.addChildAt = function (child, index) {
14640
+
14641
+ if (index >= 0 && index <= this.children.length)
14719
14642
  {
14720
- if(child.parent)
14643
+ if (child.parent)
14721
14644
  {
14722
14645
  child.parent.removeChild(child);
14723
14646
  }
@@ -14726,14 +14649,13 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
14726
14649
 
14727
14650
  this.children.splice(index, 0, child);
14728
14651
 
14729
- if(this.stage)child.setStageReference(this.stage);
14730
-
14731
14652
  return child;
14732
14653
  }
14733
14654
  else
14734
14655
  {
14735
14656
  throw new Error(child + 'addChildAt: The index '+ index +' supplied is out of bounds ' + this.children.length);
14736
14657
  }
14658
+
14737
14659
  };
14738
14660
 
14739
14661
  /**
@@ -14743,16 +14665,18 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
14743
14665
  * @param child {DisplayObject}
14744
14666
  * @param child2 {DisplayObject}
14745
14667
  */
14746
- PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
14747
- {
14748
- if(child === child2) {
14668
+ PIXI.DisplayObjectContainer.prototype.swapChildren = function (child, child2) {
14669
+
14670
+ if (child === child2)
14671
+ {
14749
14672
  return;
14750
14673
  }
14751
14674
 
14752
14675
  var index1 = this.getChildIndex(child);
14753
14676
  var index2 = this.getChildIndex(child2);
14754
14677
 
14755
- if(index1 < 0 || index2 < 0) {
14678
+ if (index1 < 0 || index2 < 0)
14679
+ {
14756
14680
  throw new Error('swapChildren: Both the supplied DisplayObjects must be a child of the caller.');
14757
14681
  }
14758
14682
 
@@ -14768,14 +14692,17 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
14768
14692
  * @param child {DisplayObject} The DisplayObject instance to identify
14769
14693
  * @return {Number} The index position of the child display object to identify
14770
14694
  */
14771
- PIXI.DisplayObjectContainer.prototype.getChildIndex = function(child)
14772
- {
14695
+ PIXI.DisplayObjectContainer.prototype.getChildIndex = function (child) {
14696
+
14773
14697
  var index = this.children.indexOf(child);
14698
+
14774
14699
  if (index === -1)
14775
14700
  {
14776
14701
  throw new Error('The supplied DisplayObject must be a child of the caller');
14777
14702
  }
14703
+
14778
14704
  return index;
14705
+
14779
14706
  };
14780
14707
 
14781
14708
  /**
@@ -14785,15 +14712,18 @@ PIXI.DisplayObjectContainer.prototype.getChildIndex = function(child)
14785
14712
  * @param child {DisplayObject} The child DisplayObject instance for which you want to change the index number
14786
14713
  * @param index {Number} The resulting index number for the child display object
14787
14714
  */
14788
- PIXI.DisplayObjectContainer.prototype.setChildIndex = function(child, index)
14789
- {
14715
+ PIXI.DisplayObjectContainer.prototype.setChildIndex = function (child, index) {
14716
+
14790
14717
  if (index < 0 || index >= this.children.length)
14791
14718
  {
14792
14719
  throw new Error('The supplied index is out of bounds');
14793
14720
  }
14721
+
14794
14722
  var currentIndex = this.getChildIndex(child);
14723
+
14795
14724
  this.children.splice(currentIndex, 1); //remove from old position
14796
14725
  this.children.splice(index, 0, child); //add at new position
14726
+
14797
14727
  };
14798
14728
 
14799
14729
  /**
@@ -14803,12 +14733,13 @@ PIXI.DisplayObjectContainer.prototype.setChildIndex = function(child, index)
14803
14733
  * @param index {Number} The index to get the child from
14804
14734
  * @return {DisplayObject} The child at the given index, if any.
14805
14735
  */
14806
- PIXI.DisplayObjectContainer.prototype.getChildAt = function(index)
14807
- {
14736
+ PIXI.DisplayObjectContainer.prototype.getChildAt = function (index) {
14737
+
14808
14738
  if (index < 0 || index >= this.children.length)
14809
14739
  {
14810
14740
  throw new Error('getChildAt: Supplied index '+ index +' does not exist in the child list, or the supplied DisplayObject must be a child of the caller');
14811
14741
  }
14742
+
14812
14743
  return this.children[index];
14813
14744
 
14814
14745
  };
@@ -14820,12 +14751,17 @@ PIXI.DisplayObjectContainer.prototype.getChildAt = function(index)
14820
14751
  * @param child {DisplayObject} The DisplayObject to remove
14821
14752
  * @return {DisplayObject} The child that was removed.
14822
14753
  */
14823
- PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
14824
- {
14825
- var index = this.children.indexOf( child );
14826
- if(index === -1)return;
14754
+ PIXI.DisplayObjectContainer.prototype.removeChild = function (child) {
14755
+
14756
+ var index = this.children.indexOf(child);
14757
+
14758
+ if (index === -1)
14759
+ {
14760
+ return;
14761
+ }
14827
14762
 
14828
- return this.removeChildAt( index );
14763
+ return this.removeChildAt(index);
14764
+
14829
14765
  };
14830
14766
 
14831
14767
  /**
@@ -14835,15 +14771,19 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
14835
14771
  * @param index {Number} The index to get the child from
14836
14772
  * @return {DisplayObject} The child that was removed.
14837
14773
  */
14838
- PIXI.DisplayObjectContainer.prototype.removeChildAt = function(index)
14839
- {
14840
- var child = this.getChildAt( index );
14841
- if(this.stage)
14842
- child.removeStageReference();
14774
+ PIXI.DisplayObjectContainer.prototype.removeChildAt = function (index) {
14775
+
14776
+ var child = this.getChildAt(index);
14777
+
14778
+ if (child)
14779
+ {
14780
+ child.parent = undefined;
14781
+
14782
+ this.children.splice(index, 1);
14783
+ }
14843
14784
 
14844
- child.parent = undefined;
14845
- this.children.splice( index, 1 );
14846
14785
  return child;
14786
+
14847
14787
  };
14848
14788
 
14849
14789
  /**
@@ -14853,21 +14793,23 @@ PIXI.DisplayObjectContainer.prototype.removeChildAt = function(index)
14853
14793
  * @param beginIndex {Number} The beginning position. Default value is 0.
14854
14794
  * @param endIndex {Number} The ending position. Default value is size of the container.
14855
14795
  */
14856
- PIXI.DisplayObjectContainer.prototype.removeChildren = function(beginIndex, endIndex)
14857
- {
14858
- var begin = beginIndex || 0;
14859
- var end = typeof endIndex === 'number' ? endIndex : this.children.length;
14860
- var range = end - begin;
14796
+ PIXI.DisplayObjectContainer.prototype.removeChildren = function (beginIndex, endIndex) {
14797
+
14798
+ if (beginIndex === undefined) { beginIndex = 0; }
14799
+ if (endIndex === undefined) { endIndex = this.children.length; }
14861
14800
 
14862
- if (range > 0 && range <= end)
14801
+ var range = endIndex - beginIndex;
14802
+
14803
+ if (range > 0 && range <= endIndex)
14863
14804
  {
14864
14805
  var removed = this.children.splice(begin, range);
14865
- for (var i = 0; i < removed.length; i++) {
14806
+
14807
+ for (var i = 0; i < removed.length; i++)
14808
+ {
14866
14809
  var child = removed[i];
14867
- if(this.stage)
14868
- child.removeStageReference();
14869
14810
  child.parent = undefined;
14870
14811
  }
14812
+
14871
14813
  return removed;
14872
14814
  }
14873
14815
  else if (range === 0 && this.children.length === 0)
@@ -14878,6 +14820,7 @@ PIXI.DisplayObjectContainer.prototype.removeChildren = function(beginIndex, endI
14878
14820
  {
14879
14821
  throw new Error( 'removeChildren: Range Error, numeric values are outside the acceptable range' );
14880
14822
  }
14823
+
14881
14824
  };
14882
14825
 
14883
14826
  /*
@@ -14886,8 +14829,8 @@ PIXI.DisplayObjectContainer.prototype.removeChildren = function(beginIndex, endI
14886
14829
  * @method updateTransform
14887
14830
  * @private
14888
14831
  */
14889
- PIXI.DisplayObjectContainer.prototype.updateTransform = function()
14890
- {
14832
+ PIXI.DisplayObjectContainer.prototype.updateTransform = function () {
14833
+
14891
14834
  if (!this.visible)
14892
14835
  {
14893
14836
  return;
@@ -14904,25 +14847,50 @@ PIXI.DisplayObjectContainer.prototype.updateTransform = function()
14904
14847
  {
14905
14848
  this.children[i].updateTransform();
14906
14849
  }
14850
+
14907
14851
  };
14908
14852
 
14909
14853
  // performance increase to avoid using call.. (10x faster)
14910
14854
  PIXI.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform = PIXI.DisplayObjectContainer.prototype.updateTransform;
14911
14855
 
14912
14856
  /**
14913
- * Retrieves the bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration.
14857
+ * Retrieves the global bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration.
14914
14858
  *
14915
14859
  * @method getBounds
14860
+ * @param {PIXI.DisplayObject|PIXI.Matrix} [targetCoordinateSpace] Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
14916
14861
  * @return {Rectangle} The rectangular bounding area
14917
14862
  */
14918
- PIXI.DisplayObjectContainer.prototype.getBounds = function()
14919
- {
14920
- if (this.children.length === 0)
14921
- {
14922
- return PIXI.EmptyRectangle;
14863
+ PIXI.DisplayObjectContainer.prototype.getBounds = function (targetCoordinateSpace) {
14864
+
14865
+ var isTargetCoordinateSpaceDisplayObject = (targetCoordinateSpace && targetCoordinateSpace instanceof PIXI.DisplayObject);
14866
+ var isTargetCoordinateSpaceThisOrParent = true;
14867
+
14868
+ if (!isTargetCoordinateSpaceDisplayObject)
14869
+ {
14870
+ targetCoordinateSpace = this;
14871
+ }
14872
+ else if (targetCoordinateSpace instanceof PIXI.DisplayObjectContainer)
14873
+ {
14874
+ isTargetCoordinateSpaceThisOrParent = targetCoordinateSpace.contains(this);
14875
+ }
14876
+ else
14877
+ {
14878
+ isTargetCoordinateSpaceThisOrParent = false;
14923
14879
  }
14924
14880
 
14925
- this.updateTransform();
14881
+ var i;
14882
+
14883
+ if (isTargetCoordinateSpaceDisplayObject)
14884
+ {
14885
+ var matrixCache = targetCoordinateSpace.worldTransform;
14886
+
14887
+ targetCoordinateSpace.worldTransform = PIXI.identityMatrix;
14888
+
14889
+ for (i = 0; i < targetCoordinateSpace.children.length; i++)
14890
+ {
14891
+ targetCoordinateSpace.children[i].updateTransform();
14892
+ }
14893
+ }
14926
14894
 
14927
14895
  var minX = Infinity;
14928
14896
  var minY = Infinity;
@@ -14936,10 +14904,10 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
14936
14904
 
14937
14905
  var childVisible = false;
14938
14906
 
14939
- for (var i = 0; i < this.children.length; i++)
14907
+ for (i = 0; i < this.children.length; i++)
14940
14908
  {
14941
14909
  var child = this.children[i];
14942
-
14910
+
14943
14911
  if (!child.visible)
14944
14912
  {
14945
14913
  continue;
@@ -14948,90 +14916,133 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
14948
14916
  childVisible = true;
14949
14917
 
14950
14918
  childBounds = this.children[i].getBounds();
14951
-
14952
- minX = minX < childBounds.x ? minX : childBounds.x;
14953
- minY = minY < childBounds.y ? minY : childBounds.y;
14919
+
14920
+ minX = (minX < childBounds.x) ? minX : childBounds.x;
14921
+ minY = (minY < childBounds.y) ? minY : childBounds.y;
14954
14922
 
14955
14923
  childMaxX = childBounds.width + childBounds.x;
14956
14924
  childMaxY = childBounds.height + childBounds.y;
14957
14925
 
14958
- maxX = maxX > childMaxX ? maxX : childMaxX;
14959
- maxY = maxY > childMaxY ? maxY : childMaxY;
14960
- }
14961
-
14962
- if (!childVisible)
14963
- {
14964
- return PIXI.EmptyRectangle;
14926
+ maxX = (maxX > childMaxX) ? maxX : childMaxX;
14927
+ maxY = (maxY > childMaxY) ? maxY : childMaxY;
14965
14928
  }
14966
14929
 
14967
14930
  var bounds = this._bounds;
14968
14931
 
14932
+ if (!childVisible)
14933
+ {
14934
+ bounds = new PIXI.Rectangle();
14935
+
14936
+ var w0 = bounds.x;
14937
+ var w1 = bounds.width + bounds.x;
14938
+
14939
+ var h0 = bounds.y;
14940
+ var h1 = bounds.height + bounds.y;
14941
+
14942
+ var worldTransform = this.worldTransform;
14943
+
14944
+ var a = worldTransform.a;
14945
+ var b = worldTransform.b;
14946
+ var c = worldTransform.c;
14947
+ var d = worldTransform.d;
14948
+ var tx = worldTransform.tx;
14949
+ var ty = worldTransform.ty;
14950
+
14951
+ var x1 = a * w1 + c * h1 + tx;
14952
+ var y1 = d * h1 + b * w1 + ty;
14953
+
14954
+ var x2 = a * w0 + c * h1 + tx;
14955
+ var y2 = d * h1 + b * w0 + ty;
14956
+
14957
+ var x3 = a * w0 + c * h0 + tx;
14958
+ var y3 = d * h0 + b * w0 + ty;
14959
+
14960
+ var x4 = a * w1 + c * h0 + tx;
14961
+ var y4 = d * h0 + b * w1 + ty;
14962
+
14963
+ maxX = x1;
14964
+ maxY = y1;
14965
+
14966
+ minX = x1;
14967
+ minY = y1;
14968
+
14969
+ minX = x2 < minX ? x2 : minX;
14970
+ minX = x3 < minX ? x3 : minX;
14971
+ minX = x4 < minX ? x4 : minX;
14972
+
14973
+ minY = y2 < minY ? y2 : minY;
14974
+ minY = y3 < minY ? y3 : minY;
14975
+ minY = y4 < minY ? y4 : minY;
14976
+
14977
+ maxX = x2 > maxX ? x2 : maxX;
14978
+ maxX = x3 > maxX ? x3 : maxX;
14979
+ maxX = x4 > maxX ? x4 : maxX;
14980
+
14981
+ maxY = y2 > maxY ? y2 : maxY;
14982
+ maxY = y3 > maxY ? y3 : maxY;
14983
+ maxY = y4 > maxY ? y4 : maxY;
14984
+ }
14985
+
14969
14986
  bounds.x = minX;
14970
14987
  bounds.y = minY;
14971
14988
  bounds.width = maxX - minX;
14972
14989
  bounds.height = maxY - minY;
14973
14990
 
14974
- return bounds;
14975
- };
14976
-
14977
- /**
14978
- * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle. The calculation takes all visible children into consideration.
14979
- *
14980
- * @method getLocalBounds
14981
- * @return {Rectangle} The rectangular bounding area
14982
- */
14983
- PIXI.DisplayObjectContainer.prototype.getLocalBounds = function()
14984
- {
14985
- var matrixCache = this.worldTransform;
14986
-
14987
- this.worldTransform = PIXI.identityMatrix;
14991
+ if (isTargetCoordinateSpaceDisplayObject)
14992
+ {
14993
+ targetCoordinateSpace.worldTransform = matrixCache;
14988
14994
 
14989
- for (var i = 0; i < this.children.length; i++)
14990
- {
14991
- this.children[i].updateTransform();
14995
+ for (i = 0; i < targetCoordinateSpace.children.length; i++)
14996
+ {
14997
+ targetCoordinateSpace.children[i].updateTransform();
14998
+ }
14992
14999
  }
14993
15000
 
14994
- var bounds = this.getBounds();
15001
+ if (!isTargetCoordinateSpaceThisOrParent)
15002
+ {
15003
+ var targetCoordinateSpaceBounds = targetCoordinateSpace.getBounds();
14995
15004
 
14996
- this.worldTransform = matrixCache;
14997
-
14998
- for (i = 0; i < this.children.length; i++)
14999
- {
15000
- this.children[i].updateTransform();
15001
- }
15005
+ bounds.x -= targetCoordinateSpaceBounds.x;
15006
+ bounds.y -= targetCoordinateSpaceBounds.y;
15007
+ }
15002
15008
 
15003
15009
  return bounds;
15010
+
15004
15011
  };
15005
15012
 
15006
15013
  /**
15007
- * Sets the containers Stage reference. This is the Stage that this object, and all of its children, is connected to.
15014
+ * Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration.
15008
15015
  *
15009
- * @method setStageReference
15010
- * @param stage {Stage} the stage that the container will have as its current stage reference
15016
+ * @method getLocalBounds
15017
+ * @return {Rectangle} The rectangular bounding area
15011
15018
  */
15012
- PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
15013
- {
15014
- this.stage = stage;
15015
-
15016
- for (var i=0; i < this.children.length; i++)
15017
- {
15018
- this.children[i].setStageReference(stage)
15019
- }
15019
+ PIXI.DisplayObjectContainer.prototype.getLocalBounds = function () {
15020
+
15021
+ return this.getBounds(this);
15022
+
15020
15023
  };
15021
15024
 
15022
15025
  /**
15023
- * Removes the current stage reference from the container and all of its children.
15024
- *
15025
- * @method removeStageReference
15026
- */
15027
- PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
15028
- {
15029
- for (var i = 0; i < this.children.length; i++)
15026
+ * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.
15027
+ *
15028
+ * @method contains
15029
+ * @param {DisplayObject} child
15030
+ * @returns {boolean}
15031
+ */
15032
+ PIXI.DisplayObjectContainer.prototype.contains = function (child) {
15033
+
15034
+ if (!child)
15030
15035
  {
15031
- this.children[i].removeStageReference();
15036
+ return false;
15037
+ }
15038
+ else if (child === this)
15039
+ {
15040
+ return true;
15041
+ }
15042
+ else
15043
+ {
15044
+ return this.contains(child.parent);
15032
15045
  }
15033
-
15034
- this.stage = null;
15035
15046
  };
15036
15047
 
15037
15048
  /**
@@ -15041,9 +15052,12 @@ PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
15041
15052
  * @param renderSession {RenderSession}
15042
15053
  * @private
15043
15054
  */
15044
- PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
15045
- {
15046
- if (!this.visible || this.alpha <= 0) return;
15055
+ PIXI.DisplayObjectContainer.prototype._renderWebGL = function (renderSession) {
15056
+
15057
+ if (!this.visible || this.alpha <= 0)
15058
+ {
15059
+ return;
15060
+ }
15047
15061
 
15048
15062
  if (this._cacheAsBitmap)
15049
15063
  {
@@ -15090,6 +15104,7 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
15090
15104
  this.children[i]._renderWebGL(renderSession);
15091
15105
  }
15092
15106
  }
15107
+
15093
15108
  };
15094
15109
 
15095
15110
  /**
@@ -15099,9 +15114,12 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
15099
15114
  * @param renderSession {RenderSession}
15100
15115
  * @private
15101
15116
  */
15102
- PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
15103
- {
15104
- if (this.visible === false || this.alpha === 0) return;
15117
+ PIXI.DisplayObjectContainer.prototype._renderCanvas = function (renderSession) {
15118
+
15119
+ if (this.visible === false || this.alpha === 0)
15120
+ {
15121
+ return;
15122
+ }
15105
15123
 
15106
15124
  if (this._cacheAsBitmap)
15107
15125
  {
@@ -15126,6 +15144,66 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
15126
15144
 
15127
15145
  };
15128
15146
 
15147
+ /**
15148
+ * The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
15149
+ *
15150
+ * @property width
15151
+ * @type Number
15152
+ */
15153
+ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
15154
+
15155
+ get: function() {
15156
+ return this.getLocalBounds().width * this.scale.x;
15157
+ },
15158
+
15159
+ set: function(value) {
15160
+
15161
+ var width = this.getLocalBounds().width;
15162
+
15163
+ if (width !== 0)
15164
+ {
15165
+ this.scale.x = value / width;
15166
+ }
15167
+ else
15168
+ {
15169
+ this.scale.x = 1;
15170
+ }
15171
+
15172
+ this._width = value;
15173
+ }
15174
+ });
15175
+
15176
+ /**
15177
+ * The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
15178
+ *
15179
+ * @property height
15180
+ * @type Number
15181
+ */
15182
+ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
15183
+
15184
+ get: function() {
15185
+ return this.getLocalBounds().height * this.scale.y;
15186
+ },
15187
+
15188
+ set: function(value) {
15189
+
15190
+ var height = this.getLocalBounds().height;
15191
+
15192
+ if (height !== 0)
15193
+ {
15194
+ this.scale.y = value / height;
15195
+ }
15196
+ else
15197
+ {
15198
+ this.scale.y = 1;
15199
+ }
15200
+
15201
+ this._height = value;
15202
+ }
15203
+
15204
+ });
15205
+
15206
+
15129
15207
  /**
15130
15208
  * @author Mat Groves http://matgroves.com/ @Doormat23
15131
15209
  */
@@ -15137,14 +15215,9 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
15137
15215
  * @extends DisplayObjectContainer
15138
15216
  * @constructor
15139
15217
  * @param texture {Texture} The texture for this sprite
15140
- *
15141
- * A sprite can be created directly from an image like this :
15142
- * var sprite = new PIXI.Sprite.fromImage('assets/image.png');
15143
- * yourStage.addChild(sprite);
15144
- * then obviously don't forget to add it to the stage you have already created
15145
15218
  */
15146
- PIXI.Sprite = function(texture)
15147
- {
15219
+ PIXI.Sprite = function (texture) {
15220
+
15148
15221
  PIXI.DisplayObjectContainer.call(this);
15149
15222
 
15150
15223
  /**
@@ -15224,7 +15297,8 @@ PIXI.Sprite = function(texture)
15224
15297
  this.blendMode = PIXI.blendModes.NORMAL;
15225
15298
 
15226
15299
  /**
15227
- * The shader that will be used to render the texture to the stage. Set to null to remove a current shader.
15300
+ * The shader that will be used to render this Sprite.
15301
+ * Set to null to remove a current shader.
15228
15302
  *
15229
15303
  * @property shader
15230
15304
  * @type AbstractFilter
@@ -15444,6 +15518,36 @@ PIXI.Sprite.prototype.getBounds = function(matrix)
15444
15518
  return bounds;
15445
15519
  };
15446
15520
 
15521
+ /**
15522
+ * Retrieves the non-global local bounds of the Sprite as a rectangle. The calculation takes all visible children into consideration.
15523
+ *
15524
+ * @method getLocalBounds
15525
+ * @return {Rectangle} The rectangular bounding area
15526
+ */
15527
+ PIXI.Sprite.prototype.getLocalBounds = function () {
15528
+
15529
+ var matrixCache = this.worldTransform;
15530
+
15531
+ this.worldTransform = PIXI.identityMatrix;
15532
+
15533
+ for (var i = 0; i < this.children.length; i++)
15534
+ {
15535
+ this.children[i].updateTransform();
15536
+ }
15537
+
15538
+ var bounds = this.getBounds();
15539
+
15540
+ this.worldTransform = matrixCache;
15541
+
15542
+ for (i = 0; i < this.children.length; i++)
15543
+ {
15544
+ this.children[i].updateTransform();
15545
+ }
15546
+
15547
+ return bounds;
15548
+
15549
+ };
15550
+
15447
15551
  /**
15448
15552
  * Renders the object using the WebGL renderer
15449
15553
  *
@@ -15631,8 +15735,6 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
15631
15735
 
15632
15736
  var container = new PIXI.SpriteBatch();
15633
15737
 
15634
- stage.addChild(container);
15635
-
15636
15738
  for(var i = 0; i < 100; i++)
15637
15739
  {
15638
15740
  var sprite = new PIXI.Sprite.fromImage("myImage.png");
@@ -20316,12 +20418,12 @@ PIXI.CanvasRenderer = function (game) {
20316
20418
  PIXI.CanvasRenderer.prototype.constructor = PIXI.CanvasRenderer;
20317
20419
 
20318
20420
  /**
20319
- * Renders the Stage to this canvas view
20421
+ * Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view.
20320
20422
  *
20321
20423
  * @method render
20322
- * @param stage {Stage} the Stage element to be rendered
20424
+ * @param root {Phaser.Stage|PIXI.DisplayObjectContainer} The root element to be rendered.
20323
20425
  */
20324
- PIXI.CanvasRenderer.prototype.render = function (stage) {
20426
+ PIXI.CanvasRenderer.prototype.render = function (root) {
20325
20427
 
20326
20428
  this.context.setTransform(1, 0, 0, 1, 0, 0);
20327
20429
 
@@ -20345,17 +20447,18 @@ PIXI.CanvasRenderer.prototype.render = function (stage) {
20345
20447
  {
20346
20448
  this.context.clearRect(0, 0, this.width, this.height);
20347
20449
  }
20348
- else
20450
+ else if (root._bgColor)
20349
20451
  {
20350
- this.context.fillStyle = stage._bgColor.rgba;
20452
+ this.context.fillStyle = root._bgColor.rgba;
20351
20453
  this.context.fillRect(0, 0, this.width , this.height);
20352
20454
  }
20353
20455
  }
20354
20456
 
20355
- this.renderDisplayObject(stage);
20457
+ this.renderDisplayObject(root);
20356
20458
 
20357
20459
  };
20358
20460
 
20461
+
20359
20462
  /**
20360
20463
  * Removes everything from the renderer and optionally removes the Canvas DOM element.
20361
20464
  *
@@ -22639,7 +22742,6 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
22639
22742
 
22640
22743
  var root = this;
22641
22744
 
22642
- /* global Phaser:true */
22643
22745
  /**
22644
22746
  * @author Richard Davey <rich@photonstorm.com>
22645
22747
  * @copyright 2016 Photon Storm Ltd.
@@ -22649,14 +22751,14 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
22649
22751
  /**
22650
22752
  * @namespace Phaser
22651
22753
  */
22652
- var Phaser = Phaser || {
22754
+ var Phaser = Phaser || { // jshint ignore:line
22653
22755
 
22654
22756
  /**
22655
22757
  * The Phaser version number.
22656
22758
  * @constant
22657
22759
  * @type {string}
22658
22760
  */
22659
- VERSION: '2.6.1',
22761
+ VERSION: '2.6.2',
22660
22762
 
22661
22763
  /**
22662
22764
  * An array of Phaser game instances.
@@ -23242,7 +23344,7 @@ if (!Array.isArray)
23242
23344
  {
23243
23345
  Array.isArray = function (arg)
23244
23346
  {
23245
- return Object.prototype.toString.call(arg) == '[object Array]';
23347
+ return Object.prototype.toString.call(arg) === '[object Array]';
23246
23348
  };
23247
23349
  }
23248
23350
 
@@ -24265,7 +24367,9 @@ Phaser.Circle.contains = function (a, x, y) {
24265
24367
  * @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
24266
24368
  */
24267
24369
  Phaser.Circle.equals = function (a, b) {
24268
- return (a.x == b.x && a.y == b.y && a.diameter == b.diameter);
24370
+
24371
+ return (a.x === b.x && a.y === b.y && a.diameter === b.diameter);
24372
+
24269
24373
  };
24270
24374
 
24271
24375
  /**
@@ -24277,7 +24381,9 @@ Phaser.Circle.equals = function (a, b) {
24277
24381
  * @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false.
24278
24382
  */
24279
24383
  Phaser.Circle.intersects = function (a, b) {
24384
+
24280
24385
  return (Phaser.Math.distance(a.x, a.y, b.x, b.y) <= (a.radius + b.radius));
24386
+
24281
24387
  };
24282
24388
 
24283
24389
  /**
@@ -24982,7 +25088,7 @@ Phaser.Line.prototype = {
24982
25088
 
24983
25089
  var i = 1;
24984
25090
 
24985
- while (!((x1 == x2) && (y1 == y2)))
25091
+ while (!((x1 === x2) && (y1 === y2)))
24986
25092
  {
24987
25093
  var e2 = err << 1;
24988
25094
 
@@ -25316,7 +25422,7 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
25316
25422
  *
25317
25423
  * The for the purposes of this function rectangles are considered 'solid'.
25318
25424
  *
25319
- * @method intersectsRectangle
25425
+ * @method Phaser.Line.intersectsRectangle
25320
25426
  * @param {Phaser.Line} line - The line to check for intersection with.
25321
25427
  * @param {Phaser.Rectangle|object} rect - The rectangle, or rectangle-like object, to check for intersection with.
25322
25428
  * @return {boolean} True if the line intersects with the rectangle edges, or starts or ends within the rectangle.
@@ -27951,7 +28057,7 @@ Phaser.Rectangle.containsRect = function (a, b) {
27951
28057
  */
27952
28058
  Phaser.Rectangle.equals = function (a, b) {
27953
28059
 
27954
- return (a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height);
28060
+ return (a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height);
27955
28061
 
27956
28062
  };
27957
28063
 
@@ -31772,7 +31878,11 @@ Phaser.Stage.prototype.updateTransform = function () {
31772
31878
  */
31773
31879
  Phaser.Stage.prototype.checkVisibility = function () {
31774
31880
 
31775
- if (document.webkitHidden !== undefined)
31881
+ if (document.hidden !== undefined)
31882
+ {
31883
+ this._hiddenVar = 'visibilitychange';
31884
+ }
31885
+ else if (document.webkitHidden !== undefined)
31776
31886
  {
31777
31887
  this._hiddenVar = 'webkitvisibilitychange';
31778
31888
  }
@@ -31784,10 +31894,6 @@ Phaser.Stage.prototype.checkVisibility = function () {
31784
31894
  {
31785
31895
  this._hiddenVar = 'msvisibilitychange';
31786
31896
  }
31787
- else if (document.hidden !== undefined)
31788
- {
31789
- this._hiddenVar = 'visibilitychange';
31790
- }
31791
31897
  else
31792
31898
  {
31793
31899
  this._hiddenVar = null;
@@ -32276,6 +32382,13 @@ Phaser.Group.RETURN_TOTAL = 1;
32276
32382
  */
32277
32383
  Phaser.Group.RETURN_CHILD = 2;
32278
32384
 
32385
+ /**
32386
+ * A returnType value, as specified in {@link #iterate} eg.
32387
+ * @constant
32388
+ * @type {integer}
32389
+ */
32390
+ Phaser.Group.RETURN_ALL = 3;
32391
+
32279
32392
  /**
32280
32393
  * A sort ordering value, as specified in {@link #sort} eg.
32281
32394
  * @constant
@@ -32348,7 +32461,7 @@ Phaser.Group.prototype.add = function (child, silent, index) {
32348
32461
  this.addToHash(child);
32349
32462
  }
32350
32463
 
32351
- if (this.inputEnableChildren && !child.inputEnabled)
32464
+ if (this.inputEnableChildren && (!child.input || child.inputEnabled))
32352
32465
  {
32353
32466
  child.inputEnabled = true;
32354
32467
  }
@@ -32637,7 +32750,7 @@ Phaser.Group.prototype.updateZ = function () {
32637
32750
  * the `alignTo` method in order to be positioned by this call. All default Phaser Game Objects have
32638
32751
  * this.
32639
32752
  *
32640
- * The grid dimensions are determined by the first four arguments. The `rows` and `columns` arguments
32753
+ * The grid dimensions are determined by the first four arguments. The `width` and `height` arguments
32641
32754
  * relate to the width and height of the grid respectively.
32642
32755
  *
32643
32756
  * For example if the Group had 100 children in it:
@@ -32651,13 +32764,13 @@ Phaser.Group.prototype.updateZ = function () {
32651
32764
  *
32652
32765
  * This will align the children into a grid of 25x4, again using 32 pixels per grid cell.
32653
32766
  *
32654
- * You can choose to set _either_ the `rows` or `columns` value to -1. Doing so tells the method
32767
+ * You can choose to set _either_ the `width` or `height` value to -1. Doing so tells the method
32655
32768
  * to keep on aligning children until there are no children left. For example if this Group had
32656
32769
  * 48 children in it, the following:
32657
32770
  *
32658
32771
  * `Group.align(-1, 8, 32, 32)`
32659
32772
  *
32660
- * ... will align the children so that there are 8 columns vertically (the second argument),
32773
+ * ... will align the children so that there are 8 children vertically (the second argument),
32661
32774
  * and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48)
32662
32775
  *
32663
32776
  * You can also do:
@@ -32675,26 +32788,27 @@ Phaser.Group.prototype.updateZ = function () {
32675
32788
  * The final argument; `offset` lets you start the alignment from a specific child index.
32676
32789
  *
32677
32790
  * @method Phaser.Group#align
32678
- * @param {integer} rows - The number of rows, or width, of the grid. Set to -1 for a dynamic width.
32679
- * @param {integer} columns - The number of columns, or height, of the grid. Set to -1 for a dynamic height.
32791
+ * @param {integer} width - The width of the grid in items (not pixels). Set to -1 for a dynamic width. If -1 then you must set an explicit height value.
32792
+ * @param {integer} height - The height of the grid in items (not pixels). Set to -1 for a dynamic height. If -1 then you must set an explicit width value.
32680
32793
  * @param {integer} cellWidth - The width of each grid cell, in pixels.
32681
32794
  * @param {integer} cellHeight - The height of each grid cell, in pixels.
32682
32795
  * @param {integer} [position] - The position constant. One of `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`, `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`.
32683
32796
  * @param {integer} [offset=0] - Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value.
32797
+ * @return {boolean} True if the Group children were aligned, otherwise false.
32684
32798
  */
32685
- Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, position, offset) {
32799
+ Phaser.Group.prototype.align = function (width, height, cellWidth, cellHeight, position, offset) {
32686
32800
 
32687
32801
  if (position === undefined) { position = Phaser.TOP_LEFT; }
32688
32802
  if (offset === undefined) { offset = 0; }
32689
32803
 
32690
- if (this.children.length === 0 || offset > this.children.length || (rows === -1 && columns === -1))
32804
+ if (this.children.length === 0 || offset > this.children.length || (width === -1 && height === -1))
32691
32805
  {
32692
- return;
32806
+ return false;
32693
32807
  }
32694
32808
 
32695
32809
  var r = new Phaser.Rectangle(0, 0, cellWidth, cellHeight);
32696
- var w = (rows * cellWidth);
32697
- var h = (columns * cellHeight);
32810
+ var w = (width * cellWidth);
32811
+ var h = (height * cellHeight);
32698
32812
 
32699
32813
  for (var i = offset; i < this.children.length; i++)
32700
32814
  {
@@ -32709,7 +32823,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
32709
32823
  continue;
32710
32824
  }
32711
32825
 
32712
- if (rows === -1)
32826
+ if (width === -1)
32713
32827
  {
32714
32828
  // We keep laying them out horizontally until we've done them all
32715
32829
  r.y += cellHeight;
@@ -32720,7 +32834,7 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
32720
32834
  r.y = 0;
32721
32835
  }
32722
32836
  }
32723
- else if (columns === -1)
32837
+ else if (height === -1)
32724
32838
  {
32725
32839
  // We keep laying them out vertically until we've done them all
32726
32840
  r.x += cellWidth;
@@ -32744,12 +32858,14 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
32744
32858
  if (r.y === h)
32745
32859
  {
32746
32860
  // We've hit the column limit, so return, even if there are children left
32747
- return;
32861
+ return true;
32748
32862
  }
32749
32863
  }
32750
32864
  }
32751
32865
  }
32752
32866
 
32867
+ return true;
32868
+
32753
32869
  };
32754
32870
 
32755
32871
  /**
@@ -33129,34 +33245,34 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation, for
33129
33245
  if (len === 1)
33130
33246
  {
33131
33247
  if (operation === 0) { child[key[0]] = value; }
33132
- else if (operation == 1) { child[key[0]] += value; }
33133
- else if (operation == 2) { child[key[0]] -= value; }
33134
- else if (operation == 3) { child[key[0]] *= value; }
33135
- else if (operation == 4) { child[key[0]] /= value; }
33248
+ else if (operation === 1) { child[key[0]] += value; }
33249
+ else if (operation === 2) { child[key[0]] -= value; }
33250
+ else if (operation === 3) { child[key[0]] *= value; }
33251
+ else if (operation === 4) { child[key[0]] /= value; }
33136
33252
  }
33137
33253
  else if (len === 2)
33138
33254
  {
33139
33255
  if (operation === 0) { child[key[0]][key[1]] = value; }
33140
- else if (operation == 1) { child[key[0]][key[1]] += value; }
33141
- else if (operation == 2) { child[key[0]][key[1]] -= value; }
33142
- else if (operation == 3) { child[key[0]][key[1]] *= value; }
33143
- else if (operation == 4) { child[key[0]][key[1]] /= value; }
33256
+ else if (operation === 1) { child[key[0]][key[1]] += value; }
33257
+ else if (operation === 2) { child[key[0]][key[1]] -= value; }
33258
+ else if (operation === 3) { child[key[0]][key[1]] *= value; }
33259
+ else if (operation === 4) { child[key[0]][key[1]] /= value; }
33144
33260
  }
33145
33261
  else if (len === 3)
33146
33262
  {
33147
33263
  if (operation === 0) { child[key[0]][key[1]][key[2]] = value; }
33148
- else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; }
33149
- else if (operation == 2) { child[key[0]][key[1]][key[2]] -= value; }
33150
- else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; }
33151
- else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; }
33264
+ else if (operation === 1) { child[key[0]][key[1]][key[2]] += value; }
33265
+ else if (operation === 2) { child[key[0]][key[1]][key[2]] -= value; }
33266
+ else if (operation === 3) { child[key[0]][key[1]][key[2]] *= value; }
33267
+ else if (operation === 4) { child[key[0]][key[1]][key[2]] /= value; }
33152
33268
  }
33153
33269
  else if (len === 4)
33154
33270
  {
33155
33271
  if (operation === 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
33156
- else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
33157
- else if (operation == 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; }
33158
- else if (operation == 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; }
33159
- else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
33272
+ else if (operation === 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
33273
+ else if (operation === 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; }
33274
+ else if (operation === 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; }
33275
+ else if (operation === 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
33160
33276
  }
33161
33277
 
33162
33278
  return true;
@@ -33447,40 +33563,37 @@ Phaser.Group.prototype.callbackFromArray = function (child, callback, length) {
33447
33563
 
33448
33564
  // Kinda looks like a Christmas tree
33449
33565
 
33450
- if (length == 1)
33566
+ if (length === 1)
33451
33567
  {
33452
33568
  if (child[callback[0]])
33453
33569
  {
33454
33570
  return child[callback[0]];
33455
33571
  }
33456
33572
  }
33457
- else if (length == 2)
33573
+ else if (length === 2)
33458
33574
  {
33459
33575
  if (child[callback[0]][callback[1]])
33460
33576
  {
33461
33577
  return child[callback[0]][callback[1]];
33462
33578
  }
33463
33579
  }
33464
- else if (length == 3)
33580
+ else if (length === 3)
33465
33581
  {
33466
33582
  if (child[callback[0]][callback[1]][callback[2]])
33467
33583
  {
33468
33584
  return child[callback[0]][callback[1]][callback[2]];
33469
33585
  }
33470
33586
  }
33471
- else if (length == 4)
33587
+ else if (length === 4)
33472
33588
  {
33473
33589
  if (child[callback[0]][callback[1]][callback[2]][callback[3]])
33474
33590
  {
33475
33591
  return child[callback[0]][callback[1]][callback[2]][callback[3]];
33476
33592
  }
33477
33593
  }
33478
- else
33594
+ else if (child[callback])
33479
33595
  {
33480
- if (child[callback])
33481
- {
33482
- return child[callback];
33483
- }
33596
+ return child[callback];
33484
33597
  }
33485
33598
 
33486
33599
  return false;
@@ -33955,13 +34068,25 @@ Phaser.Group.prototype.descendingSortHandler = function (a, b) {
33955
34068
  */
33956
34069
  Phaser.Group.prototype.iterate = function (key, value, returnType, callback, callbackContext, args) {
33957
34070
 
33958
- if (returnType === Phaser.Group.RETURN_TOTAL && this.children.length === 0)
34071
+ if (this.children.length === 0)
33959
34072
  {
33960
- return 0;
34073
+ if (returnType === Phaser.Group.RETURN_TOTAL)
34074
+ {
34075
+ return 0;
34076
+ }
34077
+ else if (returnType === Phaser.Group.RETURN_ALL)
34078
+ {
34079
+ return [];
34080
+ }
33961
34081
  }
33962
34082
 
33963
34083
  var total = 0;
33964
34084
 
34085
+ if (returnType === Phaser.Group.RETURN_ALL)
34086
+ {
34087
+ var output = [];
34088
+ }
34089
+
33965
34090
  for (var i = 0; i < this.children.length; i++)
33966
34091
  {
33967
34092
  if (this.children[i][key] === value)
@@ -33985,6 +34110,10 @@ Phaser.Group.prototype.iterate = function (key, value, returnType, callback, cal
33985
34110
  {
33986
34111
  return this.children[i];
33987
34112
  }
34113
+ else if (returnType === Phaser.Group.RETURN_ALL)
34114
+ {
34115
+ output.push(this.children[i]);
34116
+ }
33988
34117
  }
33989
34118
  }
33990
34119
 
@@ -33992,9 +34121,15 @@ Phaser.Group.prototype.iterate = function (key, value, returnType, callback, cal
33992
34121
  {
33993
34122
  return total;
33994
34123
  }
33995
-
33996
- // RETURN_CHILD or RETURN_NONE
33997
- return null;
34124
+ else if (returnType === Phaser.Group.RETURN_ALL)
34125
+ {
34126
+ return output;
34127
+ }
34128
+ else
34129
+ {
34130
+ // RETURN_CHILD or RETURN_NONE
34131
+ return null;
34132
+ }
33998
34133
 
33999
34134
  };
34000
34135
 
@@ -34281,24 +34416,83 @@ Phaser.Group.prototype.countDead = function () {
34281
34416
  * Returns a random child from the group.
34282
34417
  *
34283
34418
  * @method Phaser.Group#getRandom
34284
- * @param {integer} [startIndex=0] - Offset from the front of the front of the group (lowest child).
34419
+ * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child).
34285
34420
  * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from.
34286
34421
  * @return {any} A random child of this Group.
34287
34422
  */
34288
34423
  Phaser.Group.prototype.getRandom = function (startIndex, length) {
34289
34424
 
34290
- if (this.children.length === 0)
34425
+ if (startIndex === undefined) { startIndex = 0; }
34426
+ if (length === undefined) { length = this.children.length; }
34427
+
34428
+ if (length === 0)
34291
34429
  {
34292
34430
  return null;
34293
34431
  }
34294
34432
 
34295
- startIndex = startIndex || 0;
34296
- length = length || this.children.length;
34297
-
34298
34433
  return Phaser.ArrayUtils.getRandomItem(this.children, startIndex, length);
34299
34434
 
34300
34435
  };
34301
34436
 
34437
+ /**
34438
+ * Returns a random child from the Group that has `exists` set to `true`.
34439
+ *
34440
+ * Optionally you can specify a start and end index. For example if this Group had 100 children,
34441
+ * and you set `startIndex` to 0 and `endIndex` to 50, it would return a random child from only
34442
+ * the first 50 children in the Group.
34443
+ *
34444
+ * @method Phaser.Group#getRandomExists
34445
+ * @param {integer} [startIndex=0] - The first child index to start the search from.
34446
+ * @param {integer} [endIndex] - The last child index to search up to.
34447
+ * @return {any} A random child of this Group that exists.
34448
+ */
34449
+ Phaser.Group.prototype.getRandomExists = function (startIndex, endIndex) {
34450
+
34451
+ var list = this.getAll('exists', true, startIndex, endIndex);
34452
+
34453
+ return this.game.rnd.pick(list);
34454
+
34455
+ };
34456
+
34457
+ /**
34458
+ * Returns all children in this Group.
34459
+ *
34460
+ * You can optionally specify a matching criteria using the `property` and `value` arguments.
34461
+ *
34462
+ * For example: `getAll('exists', true)` would return only children that have their exists property set.
34463
+ *
34464
+ * Optionally you can specify a start and end index. For example if this Group had 100 children,
34465
+ * and you set `startIndex` to 0 and `endIndex` to 50, it would return a random child from only
34466
+ * the first 50 children in the Group.
34467
+ *
34468
+ * @method Phaser.Group#getAll
34469
+ * @param {string} [property] - An optional property to test against the value argument.
34470
+ * @param {any} [value] - If property is set then Child.property must strictly equal this value to be included in the results.
34471
+ * @param {integer} [startIndex=0] - The first child index to start the search from.
34472
+ * @param {integer} [endIndex] - The last child index to search up until.
34473
+ * @return {any} A random existing child of this Group.
34474
+ */
34475
+ Phaser.Group.prototype.getAll = function (property, value, startIndex, endIndex) {
34476
+
34477
+ if (startIndex === undefined) { startIndex = 0; }
34478
+ if (endIndex === undefined) { endIndex = this.children.length; }
34479
+
34480
+ var output = [];
34481
+
34482
+ for (var i = startIndex; i < endIndex; i++)
34483
+ {
34484
+ var child = this.children[i];
34485
+
34486
+ if (property && child[property] === value)
34487
+ {
34488
+ output.push(child);
34489
+ }
34490
+ }
34491
+
34492
+ return output;
34493
+
34494
+ };
34495
+
34302
34496
  /**
34303
34497
  * Removes the given child from this group.
34304
34498
  *
@@ -34579,11 +34773,6 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
34579
34773
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34580
34774
  * visible children.
34581
34775
  *
34582
- * Note that no ancestors are factored into the result, meaning that if this Group is
34583
- * nested within another Group, with heavy transforms on it, the result of this property
34584
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34585
- * top-level descendant of Phaser.World, or untransformed parents.
34586
- *
34587
34776
  * @name Phaser.Group#centerX
34588
34777
  * @property {number} centerX
34589
34778
  */
@@ -34591,13 +34780,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", {
34591
34780
 
34592
34781
  get: function () {
34593
34782
 
34594
- return this.getBounds().centerX;
34783
+ return this.getBounds(this.parent).centerX;
34595
34784
 
34596
34785
  },
34597
34786
 
34598
34787
  set: function (value) {
34599
34788
 
34600
- var r = this.getBounds();
34789
+ var r = this.getBounds(this.parent);
34601
34790
  var offset = this.x - r.x;
34602
34791
 
34603
34792
  this.x = (value + offset) - r.halfWidth;
@@ -34612,11 +34801,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerX", {
34612
34801
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34613
34802
  * visible children.
34614
34803
  *
34615
- * Note that no ancestors are factored into the result, meaning that if this Group is
34616
- * nested within another Group, with heavy transforms on it, the result of this property
34617
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34618
- * top-level descendant of Phaser.World, or untransformed parents.
34619
- *
34620
34804
  * @name Phaser.Group#centerY
34621
34805
  * @property {number} centerY
34622
34806
  */
@@ -34624,13 +34808,13 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", {
34624
34808
 
34625
34809
  get: function () {
34626
34810
 
34627
- return this.getBounds().centerY;
34811
+ return this.getBounds(this.parent).centerY;
34628
34812
 
34629
34813
  },
34630
34814
 
34631
34815
  set: function (value) {
34632
34816
 
34633
- var r = this.getBounds();
34817
+ var r = this.getBounds(this.parent);
34634
34818
  var offset = this.y - r.y;
34635
34819
 
34636
34820
  this.y = (value + offset) - r.halfHeight;
@@ -34645,11 +34829,6 @@ Object.defineProperty(Phaser.Group.prototype, "centerY", {
34645
34829
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34646
34830
  * visible children.
34647
34831
  *
34648
- * Note that no ancestors are factored into the result, meaning that if this Group is
34649
- * nested within another Group, with heavy transforms on it, the result of this property
34650
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34651
- * top-level descendant of Phaser.World, or untransformed parents.
34652
- *
34653
34832
  * @name Phaser.Group#left
34654
34833
  * @property {number} left
34655
34834
  */
@@ -34657,13 +34836,13 @@ Object.defineProperty(Phaser.Group.prototype, "left", {
34657
34836
 
34658
34837
  get: function () {
34659
34838
 
34660
- return this.getBounds().left;
34839
+ return this.getBounds(this.parent).left;
34661
34840
 
34662
34841
  },
34663
34842
 
34664
34843
  set: function (value) {
34665
34844
 
34666
- var r = this.getBounds();
34845
+ var r = this.getBounds(this.parent);
34667
34846
  var offset = this.x - r.x;
34668
34847
 
34669
34848
  this.x = value + offset;
@@ -34677,11 +34856,6 @@ Object.defineProperty(Phaser.Group.prototype, "left", {
34677
34856
  *
34678
34857
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34679
34858
  * visible children.
34680
- *
34681
- * Note that no ancestors are factored into the result, meaning that if this Group is
34682
- * nested within another Group, with heavy transforms on it, the result of this property
34683
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34684
- * top-level descendant of Phaser.World, or untransformed parents.
34685
34859
  *
34686
34860
  * @name Phaser.Group#right
34687
34861
  * @property {number} right
@@ -34690,13 +34864,13 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
34690
34864
 
34691
34865
  get: function () {
34692
34866
 
34693
- return this.getBounds().right;
34867
+ return this.getBounds(this.parent).right;
34694
34868
 
34695
34869
  },
34696
34870
 
34697
34871
  set: function (value) {
34698
34872
 
34699
- var r = this.getBounds();
34873
+ var r = this.getBounds(this.parent);
34700
34874
  var offset = this.x - r.x;
34701
34875
 
34702
34876
  this.x = (value + offset) - r.width;
@@ -34710,11 +34884,6 @@ Object.defineProperty(Phaser.Group.prototype, "right", {
34710
34884
  *
34711
34885
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34712
34886
  * visible children.
34713
- *
34714
- * Note that no ancestors are factored into the result, meaning that if this Group is
34715
- * nested within another Group, with heavy transforms on it, the result of this property
34716
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34717
- * top-level descendant of Phaser.World, or untransformed parents.
34718
34887
  *
34719
34888
  * @name Phaser.Group#top
34720
34889
  * @property {number} top
@@ -34723,13 +34892,13 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
34723
34892
 
34724
34893
  get: function () {
34725
34894
 
34726
- return this.getBounds().top;
34895
+ return this.getBounds(this.parent).top;
34727
34896
 
34728
34897
  },
34729
34898
 
34730
34899
  set: function (value) {
34731
34900
 
34732
- var r = this.getBounds();
34901
+ var r = this.getBounds(this.parent);
34733
34902
  var offset = this.y - r.y;
34734
34903
 
34735
34904
  this.y = (value + offset);
@@ -34744,11 +34913,6 @@ Object.defineProperty(Phaser.Group.prototype, "top", {
34744
34913
  * It is derived by calling `getBounds`, calculating the Groups dimensions based on its
34745
34914
  * visible children.
34746
34915
  *
34747
- * Note that no ancestors are factored into the result, meaning that if this Group is
34748
- * nested within another Group, with heavy transforms on it, the result of this property
34749
- * is likely to be incorrect. It is safe to get and set this property if the Group is a
34750
- * top-level descendant of Phaser.World, or untransformed parents.
34751
- *
34752
34916
  * @name Phaser.Group#bottom
34753
34917
  * @property {number} bottom
34754
34918
  */
@@ -34756,13 +34920,13 @@ Object.defineProperty(Phaser.Group.prototype, "bottom", {
34756
34920
 
34757
34921
  get: function () {
34758
34922
 
34759
- return this.getBounds().bottom;
34923
+ return this.getBounds(this.parent).bottom;
34760
34924
 
34761
34925
  },
34762
34926
 
34763
34927
  set: function (value) {
34764
34928
 
34765
- var r = this.getBounds();
34929
+ var r = this.getBounds(this.parent);
34766
34930
  var offset = this.y - r.y;
34767
34931
 
34768
34932
  this.y = (value + offset) - r.height;
@@ -35901,7 +36065,7 @@ Phaser.Game.prototype = {
35901
36065
  r = 'WebGL';
35902
36066
  c++;
35903
36067
  }
35904
- else if (this.renderType == Phaser.HEADLESS)
36068
+ else if (this.renderType === Phaser.HEADLESS)
35905
36069
  {
35906
36070
  r = 'Headless';
35907
36071
  }
@@ -41172,8 +41336,6 @@ Phaser.InputHandler.prototype = {
41172
41336
  this.sprite.events.onAddedToGroup.add(this.addedToGroup, this);
41173
41337
  this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this);
41174
41338
 
41175
- this.flagged = false;
41176
-
41177
41339
  return this.sprite;
41178
41340
 
41179
41341
  },
@@ -41230,7 +41392,6 @@ Phaser.InputHandler.prototype = {
41230
41392
  reset: function () {
41231
41393
 
41232
41394
  this.enabled = false;
41233
- this.flagged = false;
41234
41395
 
41235
41396
  for (var i = 0; i < 10; i++)
41236
41397
  {
@@ -42658,7 +42819,7 @@ Phaser.Gamepad = function (game) {
42658
42819
  * @property {boolean} _gamepadSupportAvailable - Are gamepads supported in this browser or not?
42659
42820
  * @private
42660
42821
  */
42661
- this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || (navigator.userAgent.indexOf('Firefox/') != -1) || !!navigator.getGamepads;
42822
+ this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || (navigator.userAgent.indexOf('Firefox/') !== -1) || !!navigator.getGamepads;
42662
42823
 
42663
42824
  /**
42664
42825
  * Used to check for differences between earlier polls and current state of gamepads.
@@ -44799,7 +44960,7 @@ Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;
44799
44960
  * _Note_: Use `Phaser.KeyCode.KEY` instead of `Phaser.Keyboard.KEY` to refer to a key code;
44800
44961
  * the latter approach is supported for compatibility.
44801
44962
  *
44802
- * @namespace
44963
+ * @class Phaser.KeyCode
44803
44964
  */
44804
44965
  Phaser.KeyCode = {
44805
44966
  /** @static */
@@ -45009,8 +45170,10 @@ Phaser.KeyCode = {
45009
45170
  };
45010
45171
 
45011
45172
  // Duplicate Phaser.KeyCode values in Phaser.Keyboard for compatibility
45012
- for (var key in Phaser.KeyCode) {
45013
- if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/)) {
45173
+ for (var key in Phaser.KeyCode)
45174
+ {
45175
+ if (Phaser.KeyCode.hasOwnProperty(key) && !key.match(/[a-z]/))
45176
+ {
45014
45177
  Phaser.Keyboard[key] = Phaser.KeyCode[key];
45015
45178
  }
45016
45179
  }
@@ -46073,7 +46236,7 @@ Phaser.Component.Crop.prototype = {
46073
46236
  * @param {Phaser.Rectangle} rect - The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle.
46074
46237
  * @param {boolean} [copy=false] - If false `cropRect` will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect.
46075
46238
  */
46076
- crop: function(rect, copy) {
46239
+ crop: function (rect, copy) {
46077
46240
 
46078
46241
  if (copy === undefined) { copy = false; }
46079
46242
 
@@ -46110,13 +46273,18 @@ Phaser.Component.Crop.prototype = {
46110
46273
  *
46111
46274
  * @method
46112
46275
  */
46113
- updateCrop: function() {
46276
+ updateCrop: function () {
46114
46277
 
46115
46278
  if (!this.cropRect)
46116
46279
  {
46117
46280
  return;
46118
46281
  }
46119
46282
 
46283
+ var oldX = this.texture.crop.x;
46284
+ var oldY = this.texture.crop.y;
46285
+ var oldW = this.texture.crop.width;
46286
+ var oldH = this.texture.crop.height;
46287
+
46120
46288
  this._crop = Phaser.Rectangle.clone(this.cropRect, this._crop);
46121
46289
  this._crop.x += this._frame.x;
46122
46290
  this._crop.y += this._frame.y;
@@ -46139,6 +46307,11 @@ Phaser.Component.Crop.prototype = {
46139
46307
 
46140
46308
  this.texture._updateUvs();
46141
46309
 
46310
+ if (this.tint !== 0xffffff && (oldX !== cx || oldY !== cy || oldW !== cw || oldH !== ch))
46311
+ {
46312
+ this.texture.requiresReTint = true;
46313
+ }
46314
+
46142
46315
  }
46143
46316
 
46144
46317
  };
@@ -46316,6 +46489,7 @@ Phaser.Component.Destroy.prototype = {
46316
46489
  if (this._crop)
46317
46490
  {
46318
46491
  this._crop = null;
46492
+ this.cropRect = null;
46319
46493
  }
46320
46494
 
46321
46495
  if (this._frame)
@@ -49178,6 +49352,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
49178
49352
  * @extends Phaser.Component.LoadTexture
49179
49353
  * @extends Phaser.Component.Overlap
49180
49354
  * @extends Phaser.Component.Reset
49355
+ * @extends Phaser.Component.ScaleMinMax
49181
49356
  * @extends Phaser.Component.Smoothed
49182
49357
  * @constructor
49183
49358
  * @param {Phaser.Game} game - A reference to the currently running game.
@@ -49222,6 +49397,7 @@ Phaser.Component.Core.install.call(Phaser.Image.prototype, [
49222
49397
  'LoadTexture',
49223
49398
  'Overlap',
49224
49399
  'Reset',
49400
+ 'ScaleMinMax',
49225
49401
  'Smoothed'
49226
49402
  ]);
49227
49403
 
@@ -49420,7 +49596,7 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
49420
49596
  this.onOverMouseOnly = true;
49421
49597
 
49422
49598
  /**
49423
- * Suppresse the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
49599
+ * Suppress the over event if a pointer was just released and it matches the given {@link Phaser.PointerModer pointer mode bitmask}.
49424
49600
  *
49425
49601
  * This behavior was introduced in Phaser 2.3.1; this property is a soft-revert of the change.
49426
49602
  *
@@ -51615,6 +51791,8 @@ Phaser.BitmapData.prototype = {
51615
51791
  ctx.shadowOffsetX = x || 10;
51616
51792
  ctx.shadowOffsetY = y || 10;
51617
51793
  }
51794
+
51795
+ return this;
51618
51796
 
51619
51797
  },
51620
51798
 
@@ -51766,6 +51944,8 @@ Phaser.BitmapData.prototype = {
51766
51944
  ctx.fillText(text, x, y);
51767
51945
 
51768
51946
  ctx.font = prevFont;
51947
+
51948
+ return this;
51769
51949
 
51770
51950
  },
51771
51951
 
@@ -52438,6 +52618,16 @@ PIXI.Graphics = function()
52438
52618
  */
52439
52619
  this.dirty = true;
52440
52620
 
52621
+ /**
52622
+ * Used to detect if the bounds have been invalidated, by this Graphics being cleared or drawn to.
52623
+ * If this is set to true then the updateLocalBounds is called once in the postUpdate method.
52624
+ *
52625
+ * @property _boundsDirty
52626
+ * @type Boolean
52627
+ * @private
52628
+ */
52629
+ this._boundsDirty = false;
52630
+
52441
52631
  /**
52442
52632
  * Used to detect if the webgl graphics object has changed. If this is set to true then the graphics object will be recalculated.
52443
52633
  *
@@ -52529,7 +52719,7 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
52529
52719
 
52530
52720
  this.currentPath.shape.points.push(x, y);
52531
52721
  this.dirty = true;
52532
- this.updateLocalBounds();
52722
+ this._boundsDirty = true;
52533
52723
 
52534
52724
  return this;
52535
52725
  };
@@ -52584,7 +52774,7 @@ PIXI.Graphics.prototype.quadraticCurveTo = function(cpX, cpY, toX, toY)
52584
52774
  }
52585
52775
 
52586
52776
  this.dirty = true;
52587
- this.updateLocalBounds();
52777
+ this._boundsDirty = true;
52588
52778
 
52589
52779
  return this;
52590
52780
  };
@@ -52643,7 +52833,7 @@ PIXI.Graphics.prototype.bezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY)
52643
52833
  }
52644
52834
 
52645
52835
  this.dirty = true;
52646
- this.updateLocalBounds();
52836
+ this._boundsDirty = true;
52647
52837
 
52648
52838
  return this;
52649
52839
  };
@@ -52713,7 +52903,7 @@ PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
52713
52903
  }
52714
52904
 
52715
52905
  this.dirty = true;
52716
- this.updateLocalBounds();
52906
+ this._boundsDirty = true;
52717
52907
 
52718
52908
  return this;
52719
52909
  };
@@ -52799,7 +52989,7 @@ PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, ant
52799
52989
  }
52800
52990
 
52801
52991
  this.dirty = true;
52802
- this.updateLocalBounds();
52992
+ this._boundsDirty = true;
52803
52993
 
52804
52994
  return this;
52805
52995
  };
@@ -52958,6 +53148,7 @@ PIXI.Graphics.prototype.clear = function()
52958
53148
  this.filling = false;
52959
53149
 
52960
53150
  this.dirty = true;
53151
+ this._boundsDirty = true;
52961
53152
  this.clearDirty = true;
52962
53153
  this.graphicsData = [];
52963
53154
 
@@ -53248,6 +53439,32 @@ PIXI.Graphics.prototype.getBounds = function(matrix)
53248
53439
 
53249
53440
  };
53250
53441
 
53442
+ /**
53443
+ * Retrieves the non-global local bounds of the graphic shape as a rectangle. The calculation takes all visible children into consideration.
53444
+ *
53445
+ * @method getLocalBounds
53446
+ * @return {Rectangle} The rectangular bounding area
53447
+ */
53448
+ PIXI.Graphics.prototype.getLocalBounds = function () {
53449
+ var matrixCache = this.worldTransform;
53450
+
53451
+ this.worldTransform = PIXI.identityMatrix;
53452
+
53453
+ for (var i = 0; i < this.children.length; i++) {
53454
+ this.children[i].updateTransform();
53455
+ }
53456
+
53457
+ var bounds = this.getBounds();
53458
+
53459
+ this.worldTransform = matrixCache;
53460
+
53461
+ for (i = 0; i < this.children.length; i++) {
53462
+ this.children[i].updateTransform();
53463
+ }
53464
+
53465
+ return bounds;
53466
+ };
53467
+
53251
53468
  /**
53252
53469
  * Tests if a point is inside this graphics object
53253
53470
  *
@@ -53508,8 +53725,7 @@ PIXI.Graphics.prototype.drawShape = function(shape)
53508
53725
  }
53509
53726
 
53510
53727
  this.dirty = true;
53511
-
53512
- this.updateLocalBounds();
53728
+ this._boundsDirty = true;
53513
53729
 
53514
53730
  return data;
53515
53731
 
@@ -53661,175 +53877,6 @@ PIXI.GraphicsData.prototype.clone = function() {
53661
53877
  );
53662
53878
 
53663
53879
  };
53664
- /*
53665
- PolyK library
53666
- url: http://polyk.ivank.net
53667
- Released under MIT licence.
53668
-
53669
- Copyright (c) 2012 Ivan Kuckir
53670
-
53671
- Permission is hereby granted, free of charge, to any person
53672
- obtaining a copy of this software and associated documentation
53673
- files (the "Software"), to deal in the Software without
53674
- restriction, including without limitation the rights to use,
53675
- copy, modify, merge, publish, distribute, sublicense, and/or sell
53676
- copies of the Software, and to permit persons to whom the
53677
- Software is furnished to do so, subject to the following
53678
- conditions:
53679
-
53680
- The above copyright notice and this permission notice shall be
53681
- included in all copies or substantial portions of the Software.
53682
-
53683
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
53684
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
53685
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
53686
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
53687
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
53688
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
53689
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53690
- OTHER DEALINGS IN THE SOFTWARE.
53691
-
53692
- This is an amazing lib!
53693
-
53694
- Slightly modified by Mat Groves (matgroves.com);
53695
- */
53696
-
53697
- /**
53698
- * Based on the Polyk library http://polyk.ivank.net released under MIT licence.
53699
- * This is an amazing lib!
53700
- * Slightly modified by Mat Groves (matgroves.com);
53701
- * @class PolyK
53702
- */
53703
- PIXI.PolyK = {};
53704
-
53705
- /**
53706
- * Triangulates shapes for webGL graphic fills.
53707
- *
53708
- * @method Triangulate
53709
- */
53710
- PIXI.PolyK.Triangulate = function(p)
53711
- {
53712
- var sign = true;
53713
-
53714
- var n = p.length >> 1;
53715
- if(n < 3) return [];
53716
-
53717
- var tgs = [];
53718
- var avl = [];
53719
- for(var i = 0; i < n; i++) avl.push(i);
53720
-
53721
- i = 0;
53722
- var al = n;
53723
- while(al > 3)
53724
- {
53725
- var i0 = avl[(i+0)%al];
53726
- var i1 = avl[(i+1)%al];
53727
- var i2 = avl[(i+2)%al];
53728
-
53729
- var ax = p[2*i0], ay = p[2*i0+1];
53730
- var bx = p[2*i1], by = p[2*i1+1];
53731
- var cx = p[2*i2], cy = p[2*i2+1];
53732
-
53733
- var earFound = false;
53734
- if(PIXI.PolyK._convex(ax, ay, bx, by, cx, cy, sign))
53735
- {
53736
- earFound = true;
53737
- for(var j = 0; j < al; j++)
53738
- {
53739
- var vi = avl[j];
53740
- if(vi === i0 || vi === i1 || vi === i2) continue;
53741
-
53742
- if(PIXI.PolyK._PointInTriangle(p[2*vi], p[2*vi+1], ax, ay, bx, by, cx, cy)) {
53743
- earFound = false;
53744
- break;
53745
- }
53746
- }
53747
- }
53748
-
53749
- if(earFound)
53750
- {
53751
- tgs.push(i0, i1, i2);
53752
- avl.splice((i+1)%al, 1);
53753
- al--;
53754
- i = 0;
53755
- }
53756
- else if(i++ > 3*al)
53757
- {
53758
- // need to flip flip reverse it!
53759
- // reset!
53760
- if(sign)
53761
- {
53762
- tgs = [];
53763
- avl = [];
53764
- for(i = 0; i < n; i++) avl.push(i);
53765
-
53766
- i = 0;
53767
- al = n;
53768
-
53769
- sign = false;
53770
- }
53771
- else
53772
- {
53773
- // window.console.log("PIXI Warning: shape too complex to fill");
53774
- return null;
53775
- }
53776
- }
53777
- }
53778
-
53779
- tgs.push(avl[0], avl[1], avl[2]);
53780
- return tgs;
53781
- };
53782
-
53783
- /**
53784
- * Checks whether a point is within a triangle
53785
- *
53786
- * @method _PointInTriangle
53787
- * @param px {Number} x coordinate of the point to test
53788
- * @param py {Number} y coordinate of the point to test
53789
- * @param ax {Number} x coordinate of the a point of the triangle
53790
- * @param ay {Number} y coordinate of the a point of the triangle
53791
- * @param bx {Number} x coordinate of the b point of the triangle
53792
- * @param by {Number} y coordinate of the b point of the triangle
53793
- * @param cx {Number} x coordinate of the c point of the triangle
53794
- * @param cy {Number} y coordinate of the c point of the triangle
53795
- * @private
53796
- * @return {Boolean}
53797
- */
53798
- PIXI.PolyK._PointInTriangle = function(px, py, ax, ay, bx, by, cx, cy)
53799
- {
53800
- var v0x = cx-ax;
53801
- var v0y = cy-ay;
53802
- var v1x = bx-ax;
53803
- var v1y = by-ay;
53804
- var v2x = px-ax;
53805
- var v2y = py-ay;
53806
-
53807
- var dot00 = v0x*v0x+v0y*v0y;
53808
- var dot01 = v0x*v1x+v0y*v1y;
53809
- var dot02 = v0x*v2x+v0y*v2y;
53810
- var dot11 = v1x*v1x+v1y*v1y;
53811
- var dot12 = v1x*v2x+v1y*v2y;
53812
-
53813
- var invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
53814
- var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
53815
- var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
53816
-
53817
- // Check if point is in triangle
53818
- return (u >= 0) && (v >= 0) && (u + v < 1);
53819
- };
53820
-
53821
- /**
53822
- * Checks whether a shape is convex
53823
- *
53824
- * @method _convex
53825
- * @private
53826
- * @return {Boolean}
53827
- */
53828
- PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign)
53829
- {
53830
- return ((ay-by)*(cx-bx) + (bx-ax)*(cy-by) >= 0) === sign;
53831
- };
53832
-
53833
53880
  /*
53834
53881
  Copyright (c) 2016, Mapbox
53835
53882
 
@@ -55807,6 +55854,28 @@ Phaser.Graphics.prototype.preUpdate = function () {
55807
55854
 
55808
55855
  };
55809
55856
 
55857
+ /**
55858
+ * Automatically called by World
55859
+ * @method Phaser.Graphics.prototype.postUpdate
55860
+ */
55861
+ Phaser.Graphics.prototype.postUpdate = function () {
55862
+
55863
+ Phaser.Component.PhysicsBody.postUpdate.call(this);
55864
+ Phaser.Component.FixedToCamera.postUpdate.call(this);
55865
+
55866
+ if (this._boundsDirty)
55867
+ {
55868
+ this.updateLocalBounds();
55869
+ this._boundsDirty = false;
55870
+ }
55871
+
55872
+ for (var i = 0; i < this.children.length; i++)
55873
+ {
55874
+ this.children[i].postUpdate();
55875
+ }
55876
+
55877
+ };
55878
+
55810
55879
  /**
55811
55880
  * Destroy this Graphics instance.
55812
55881
  *
@@ -55943,7 +56012,6 @@ Phaser.Graphics.prototype.drawTriangles = function(vertices, indices, cull) {
55943
56012
  * @constructor
55944
56013
  * @extends PIXI.RenderTexture
55945
56014
  * @param {Phaser.Game} game - Current game instance.
55946
- * @param {string} key - Internal Phaser reference key for the render texture.
55947
56015
  * @param {number} [width=100] - The width of the render texture.
55948
56016
  * @param {number} [height=100] - The height of the render texture.
55949
56017
  * @param {string} [key=''] - The key of the RenderTexture in the Cache, if stored there.
@@ -56309,8 +56377,6 @@ Phaser.Text.prototype.destroy = function (destroyChildren) {
56309
56377
 
56310
56378
  this.texture.destroy(true);
56311
56379
 
56312
- PIXI.CanvasPool.remove(this);
56313
-
56314
56380
  Phaser.Component.Destroy.prototype.destroy.call(this, destroyChildren);
56315
56381
 
56316
56382
  };
@@ -56668,6 +56734,8 @@ Phaser.Text.prototype.updateText = function () {
56668
56734
 
56669
56735
  this.updateTexture();
56670
56736
 
56737
+ this.dirty = false;
56738
+
56671
56739
  };
56672
56740
 
56673
56741
  /**
@@ -57527,20 +57595,20 @@ Phaser.Text.prototype.updateTexture = function () {
57527
57595
  // Align the canvas based on the bounds
57528
57596
  if (this.style.boundsAlignH === 'right')
57529
57597
  {
57530
- x += this.textBounds.width - this.canvas.width;
57598
+ x += this.textBounds.width - this.canvas.width / this.resolution;
57531
57599
  }
57532
57600
  else if (this.style.boundsAlignH === 'center')
57533
57601
  {
57534
- x += this.textBounds.halfWidth - (this.canvas.width / 2);
57602
+ x += this.textBounds.halfWidth - (this.canvas.width / this.resolution / 2);
57535
57603
  }
57536
57604
 
57537
57605
  if (this.style.boundsAlignV === 'bottom')
57538
57606
  {
57539
- y += this.textBounds.height - this.canvas.height;
57607
+ y += this.textBounds.height - this.canvas.height / this.resolution;
57540
57608
  }
57541
57609
  else if (this.style.boundsAlignV === 'middle')
57542
57610
  {
57543
- y += this.textBounds.halfHeight - (this.canvas.height / 2);
57611
+ y += this.textBounds.halfHeight - (this.canvas.height / this.resolution / 2);
57544
57612
  }
57545
57613
 
57546
57614
  this.pivot.x = -x;
@@ -58655,7 +58723,8 @@ Phaser.BitmapText.prototype.scanLine = function (data, scale, text) {
58655
58723
  var kerning = (prevCharCode && charData.kerning[prevCharCode]) ? charData.kerning[prevCharCode] : 0;
58656
58724
 
58657
58725
  // Record the last space in the string and the current width
58658
- if (/(\s)/.test(text.charAt(i))) {
58726
+ if (/(\s)/.test(text.charAt(i)))
58727
+ {
58659
58728
  lastSpace = i;
58660
58729
  wrappedWidth = w;
58661
58730
  }
@@ -59924,7 +59993,7 @@ Object.defineProperty(Phaser.Rope.prototype, "segments", {
59924
59993
  * An important note about texture dimensions:
59925
59994
  *
59926
59995
  * When running under Canvas a TileSprite can use any texture size without issue. When running under WebGL the texture should ideally be
59927
- * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etch pixels width by height). If the texture isn't a power of two
59996
+ * a power of two in size (i.e. 4, 8, 16, 32, 64, 128, 256, 512, etc pixels width by height). If the texture isn't a power of two
59928
59997
  * it will be rendered to a blank canvas that is the correct size, which means you may have 'blank' areas appearing to the right and
59929
59998
  * bottom of your frame. To avoid this ensure your textures are perfect powers of two.
59930
59999
  *
@@ -61067,12 +61136,12 @@ Phaser.Device._initialize = function () {
61067
61136
  device.webApp = true;
61068
61137
  }
61069
61138
 
61070
- if (typeof window.cordova !== "undefined")
61139
+ if (typeof window.cordova !== 'undefined')
61071
61140
  {
61072
61141
  device.cordova = true;
61073
61142
  }
61074
61143
 
61075
- if (typeof process !== "undefined" && typeof require !== "undefined")
61144
+ if (typeof process !== 'undefined' && typeof require !== 'undefined')
61076
61145
  {
61077
61146
  device.node = true;
61078
61147
  }
@@ -61092,7 +61161,7 @@ Phaser.Device._initialize = function () {
61092
61161
  if (device.cocoonJS)
61093
61162
  {
61094
61163
  try {
61095
- device.cocoonJSApp = (typeof CocoonJS !== "undefined");
61164
+ device.cocoonJSApp = (typeof CocoonJS !== 'undefined');
61096
61165
  }
61097
61166
  catch(error)
61098
61167
  {
@@ -61100,7 +61169,7 @@ Phaser.Device._initialize = function () {
61100
61169
  }
61101
61170
  }
61102
61171
 
61103
- if (typeof window.ejecta !== "undefined")
61172
+ if (typeof window.ejecta !== 'undefined')
61104
61173
  {
61105
61174
  device.ejecta = true;
61106
61175
  }
@@ -61225,42 +61294,6 @@ Phaser.Device._initialize = function () {
61225
61294
 
61226
61295
  }
61227
61296
 
61228
- /**
61229
- * Check PixelRatio, iOS device, Vibration API, ArrayBuffers and endianess.
61230
- */
61231
- function _checkDevice () {
61232
-
61233
- device.pixelRatio = window['devicePixelRatio'] || 1;
61234
- device.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
61235
- device.iPhone4 = (device.pixelRatio == 2 && device.iPhone);
61236
- device.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1;
61237
-
61238
- if (typeof Int8Array !== 'undefined')
61239
- {
61240
- device.typedArray = true;
61241
- }
61242
- else
61243
- {
61244
- device.typedArray = false;
61245
- }
61246
-
61247
- if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined')
61248
- {
61249
- device.littleEndian = _checkIsLittleEndian();
61250
- device.LITTLE_ENDIAN = device.littleEndian;
61251
- }
61252
-
61253
- device.support32bit = (typeof ArrayBuffer !== "undefined" && typeof Uint8ClampedArray !== "undefined" && typeof Int32Array !== "undefined" && device.littleEndian !== null && _checkIsUint8ClampedImageData());
61254
-
61255
- navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
61256
-
61257
- if (navigator.vibrate)
61258
- {
61259
- device.vibration = true;
61260
- }
61261
-
61262
- }
61263
-
61264
61297
  /**
61265
61298
  * Check Little or Big Endian system.
61266
61299
  *
@@ -61277,12 +61310,12 @@ Phaser.Device._initialize = function () {
61277
61310
  b[2] = 0xc3;
61278
61311
  b[3] = 0xd4;
61279
61312
 
61280
- if (c[0] == 0xd4c3b2a1)
61313
+ if (c[0] === 0xd4c3b2a1)
61281
61314
  {
61282
61315
  return true;
61283
61316
  }
61284
61317
 
61285
- if (c[0] == 0xa1b2c3d4)
61318
+ if (c[0] === 0xa1b2c3d4)
61286
61319
  {
61287
61320
  return false;
61288
61321
  }
@@ -61322,6 +61355,42 @@ Phaser.Device._initialize = function () {
61322
61355
 
61323
61356
  }
61324
61357
 
61358
+ /**
61359
+ * Check PixelRatio, iOS device, Vibration API, ArrayBuffers and endianess.
61360
+ */
61361
+ function _checkDevice () {
61362
+
61363
+ device.pixelRatio = window['devicePixelRatio'] || 1;
61364
+ device.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') !== -1;
61365
+ device.iPhone4 = (device.pixelRatio === 2 && device.iPhone);
61366
+ device.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') !== -1;
61367
+
61368
+ if (typeof Int8Array !== 'undefined')
61369
+ {
61370
+ device.typedArray = true;
61371
+ }
61372
+ else
61373
+ {
61374
+ device.typedArray = false;
61375
+ }
61376
+
61377
+ if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined')
61378
+ {
61379
+ device.littleEndian = _checkIsLittleEndian();
61380
+ device.LITTLE_ENDIAN = device.littleEndian;
61381
+ }
61382
+
61383
+ device.support32bit = (typeof ArrayBuffer !== 'undefined' && typeof Uint8ClampedArray !== 'undefined' && typeof Int32Array !== 'undefined' && device.littleEndian !== null && _checkIsUint8ClampedImageData());
61384
+
61385
+ navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
61386
+
61387
+ if (navigator.vibrate)
61388
+ {
61389
+ device.vibration = true;
61390
+ }
61391
+
61392
+ }
61393
+
61325
61394
  /**
61326
61395
  * Check whether the host environment support 3D CSS.
61327
61396
  */
@@ -62292,6 +62361,87 @@ Phaser.Math = {
62292
62361
 
62293
62362
  },
62294
62363
 
62364
+ /**
62365
+ * Rotates currentAngle towards targetAngle, taking the shortest rotation distance.
62366
+ * The lerp argument is the amount to rotate by in this call.
62367
+ *
62368
+ * @method Phaser.Math#rotateToAngle
62369
+ * @param {number} currentAngle - The current angle, in radians.
62370
+ * @param {number} targetAngle - The target angle to rotate to, in radians.
62371
+ * @param {number} [lerp=0.05] - The lerp value to add to the current angle.
62372
+ * @return {number} The adjusted angle.
62373
+ */
62374
+ rotateToAngle: function (currentAngle, targetAngle, lerp) {
62375
+
62376
+ if (lerp === undefined) { lerp = 0.05; }
62377
+
62378
+ if (currentAngle === targetAngle)
62379
+ {
62380
+ return currentAngle;
62381
+ }
62382
+
62383
+ if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (Phaser.Math.PI2 - lerp))
62384
+ {
62385
+ currentAngle = targetAngle;
62386
+ }
62387
+ else
62388
+ {
62389
+ if (Math.abs(targetAngle - currentAngle) > Math.PI)
62390
+ {
62391
+ if (targetAngle < currentAngle)
62392
+ {
62393
+ targetAngle += Phaser.Math.PI2;
62394
+ }
62395
+ else
62396
+ {
62397
+ targetAngle -= Phaser.Math.PI2;
62398
+ }
62399
+ }
62400
+
62401
+ if (targetAngle > currentAngle)
62402
+ {
62403
+ currentAngle += lerp;
62404
+ }
62405
+ else if (targetAngle < currentAngle)
62406
+ {
62407
+ currentAngle -= lerp;
62408
+ }
62409
+ }
62410
+
62411
+ return currentAngle;
62412
+
62413
+ },
62414
+
62415
+ /**
62416
+ * Gets the shortest angle between `angle1` and `angle2`.
62417
+ * Both angles must be in the range -180 to 180, which is the same clamped
62418
+ * range that `sprite.angle` uses, so you can pass in two sprite angles to
62419
+ * this method, and get the shortest angle back between the two of them.
62420
+ *
62421
+ * The angle returned will be in the same range. If the returned angle is
62422
+ * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's
62423
+ * a clockwise rotation.
62424
+ *
62425
+ * @method Phaser.Math#getShortestAngle
62426
+ * @param {number} angle1 - The first angle. In the range -180 to 180.
62427
+ * @param {number} angle2 - The second angle. In the range -180 to 180.
62428
+ * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation.
62429
+ */
62430
+ getShortestAngle: function (angle1, angle2) {
62431
+
62432
+ var difference = angle2 - angle1;
62433
+
62434
+ if (difference === 0)
62435
+ {
62436
+ return 0;
62437
+ }
62438
+
62439
+ var times = Math.floor((difference - (-180)) / 360);
62440
+
62441
+ return difference - (times * 360);
62442
+
62443
+ },
62444
+
62295
62445
  /**
62296
62446
  * Find the angle of a segment from (x1, y1) -> (x2, y2).
62297
62447
  *
@@ -63943,7 +64093,7 @@ Phaser.Net.prototype = {
63943
64093
 
63944
64094
  if (key.length > 1)
63945
64095
  {
63946
- if (parameter && parameter == this.decodeURI(key[0]))
64096
+ if (parameter && parameter === this.decodeURI(key[0]))
63947
64097
  {
63948
64098
  return this.decodeURI(key[1]);
63949
64099
  }
@@ -68082,9 +68232,6 @@ Phaser.AnimationManager.prototype = {
68082
68232
 
68083
68233
  this.currentAnim = this._anims[name];
68084
68234
 
68085
- // This shouldn't be set until the Animation is played, surely?
68086
- // this.currentFrame = this.currentAnim.currentFrame;
68087
-
68088
68235
  if (this.sprite.tilingTexture)
68089
68236
  {
68090
68237
  this.sprite.refreshTexture = true;
@@ -68688,29 +68835,33 @@ Phaser.Animation.prototype = {
68688
68835
  },
68689
68836
 
68690
68837
  /**
68691
- * Reverses the animation direction
68692
- *
68693
- * @method Phaser.Animation#reverse
68694
- * @return {Phaser.Animation} The animation instance.
68695
- * */
68838
+ * Reverses the animation direction.
68839
+ *
68840
+ * @method Phaser.Animation#reverse
68841
+ * @return {Phaser.Animation} The animation instance.
68842
+ */
68696
68843
  reverse: function () {
68844
+
68697
68845
  this.reversed = !this.reversed;
68698
68846
 
68699
68847
  return this;
68848
+
68700
68849
  },
68701
68850
 
68702
68851
  /**
68703
- * Reverses the animation direction for the current/next animation only
68704
- * Once the onComplete event is called this method will be called again and revert
68705
- * the reversed state.
68706
- *
68707
- * @method Phaser.Animation#reverseOnce
68708
- * @return {Phaser.Animation} The animation instance.
68709
- * */
68852
+ * Reverses the animation direction for the current/next animation only
68853
+ * Once the onComplete event is called this method will be called again and revert
68854
+ * the reversed state.
68855
+ *
68856
+ * @method Phaser.Animation#reverseOnce
68857
+ * @return {Phaser.Animation} The animation instance.
68858
+ */
68710
68859
  reverseOnce: function () {
68711
- this.onComplete.addOnce(this.reverse.bind(this));
68860
+
68861
+ this.onComplete.addOnce(this.reverse, this);
68712
68862
 
68713
68863
  return this.reverse();
68864
+
68714
68865
  },
68715
68866
 
68716
68867
  /**
@@ -68861,9 +69012,12 @@ Phaser.Animation.prototype = {
68861
69012
  // And what's left now?
68862
69013
  this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
68863
69014
 
68864
- if (this.isReversed){
69015
+ if (this.isReversed)
69016
+ {
68865
69017
  this._frameIndex -= this._frameSkip;
68866
- }else{
69018
+ }
69019
+ else
69020
+ {
68867
69021
  this._frameIndex += this._frameSkip;
68868
69022
  }
68869
69023
 
@@ -68874,7 +69028,8 @@ Phaser.Animation.prototype = {
68874
69028
  // Update current state before event callback
68875
69029
  this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
68876
69030
 
68877
- if (this.isReversed){
69031
+ if (this.isReversed)
69032
+ {
68878
69033
  this._frameIndex = this._frames.length - 1 - this._frameIndex;
68879
69034
  }
68880
69035
 
@@ -69212,19 +69367,19 @@ Object.defineProperty(Phaser.Animation.prototype, 'frame', {
69212
69367
 
69213
69368
  /**
69214
69369
  * @name Phaser.Animation#speed
69215
- * @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Minimum value is 1.
69370
+ * @property {number} speed - Gets or sets the current speed of the animation in frames per second. Changing this in a playing animation will take effect from the next frame. Value must be greater than 0.
69216
69371
  */
69217
69372
  Object.defineProperty(Phaser.Animation.prototype, 'speed', {
69218
69373
 
69219
69374
  get: function () {
69220
69375
 
69221
- return Math.round(1000 / this.delay);
69376
+ return 1000 / this.delay;
69222
69377
 
69223
69378
  },
69224
69379
 
69225
69380
  set: function (value) {
69226
69381
 
69227
- if (value >= 1)
69382
+ if (value > 0)
69228
69383
  {
69229
69384
  this.delay = 1000 / value;
69230
69385
  }
@@ -69997,15 +70152,16 @@ Phaser.AnimationParser = {
69997
70152
  signature.forEach( function(key) {
69998
70153
  if (!json[key])
69999
70154
  {
70000
- console.warn("Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing '" + key + "' key.");
70155
+ console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "' + key + '" key.');
70001
70156
  console.log(json);
70002
70157
  return;
70003
70158
  }
70004
70159
  });
70005
70160
 
70006
70161
  // For this purpose, I only care about parsing tilemaps with a single layer.
70007
- if(json['layers'].length != 1) {
70008
- console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.");
70162
+ if (json['layers'].length !== 1)
70163
+ {
70164
+ console.warn('Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.');
70009
70165
  console.log(json);
70010
70166
  return;
70011
70167
  }
@@ -72253,12 +72409,23 @@ Phaser.Loader = function (game) {
72253
72409
  * Used to map the application mime-types to to the Accept header in XHR requests.
72254
72410
  * If you don't require these mappings, or they cause problems on your server, then
72255
72411
  * remove them from the headers object and the XHR request will not try to use them.
72412
+ *
72413
+ * This object can also be used to set the `X-Requested-With` header to
72414
+ * `XMLHttpRequest` (or any other value you need). To enable this do:
72415
+ *
72416
+ * `this.load.headers.requestedWith = 'XMLHttpRequest'`
72417
+ *
72418
+ * before adding anything to the Loader. The XHR loader will then call:
72419
+ *
72420
+ * `setRequestHeader('X-Requested-With', this.headers['requestedWith'])`
72421
+ *
72256
72422
  * @property {object} headers
72257
72423
  * @default
72258
72424
  */
72259
72425
  this.headers = {
72260
- json: "application/json",
72261
- xml: "application/xml"
72426
+ "requestedWith": false,
72427
+ "json": "application/json",
72428
+ "xml": "application/xml"
72262
72429
  };
72263
72430
 
72264
72431
  /**
@@ -73182,7 +73349,7 @@ Phaser.Loader.prototype = {
73182
73349
  *
73183
73350
  * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.
73184
73351
  *
73185
- * @method Phaser.Loader#audiosprite
73352
+ * @method Phaser.Loader#audioSprite
73186
73353
  * @param {string} key - Unique asset key of the audio file.
73187
73354
  * @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL.
73188
73355
  * @param {string} [jsonURL=null] - The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null.
@@ -73301,6 +73468,10 @@ Phaser.Loader.prototype = {
73301
73468
  /**
73302
73469
  * Adds a Tile Map data file to the current load queue.
73303
73470
  *
73471
+ * Phaser can load data in two different formats: CSV and Tiled JSON.
73472
+ *
73473
+ * Tiled is a free software package, specifically for creating tilemaps, and is available from http://www.mapeditor.org
73474
+ *
73304
73475
  * You can choose to either load the data externally, by providing a URL to a json file.
73305
73476
  * Or you can pass in a JSON object or String via the `data` parameter.
73306
73477
  * If you pass a String the data is automatically run through `JSON.parse` and then immediately added to the Phaser.Cache.
@@ -74477,9 +74648,14 @@ Phaser.Loader.prototype = {
74477
74648
  xhr.open("GET", url, true);
74478
74649
  xhr.responseType = type;
74479
74650
 
74651
+ if (this.headers['requestedWith'] !== false)
74652
+ {
74653
+ xhr.setRequestHeader('X-Requested-With', this.headers['requestedWith']);
74654
+ }
74655
+
74480
74656
  if (this.headers[file.type])
74481
74657
  {
74482
- xhr.setRequestHeader("Accept", this.headers[file.type]);
74658
+ xhr.setRequestHeader('Accept', this.headers[file.type]);
74483
74659
  }
74484
74660
 
74485
74661
  onerror = onerror || this.fileError;
@@ -74489,7 +74665,7 @@ Phaser.Loader.prototype = {
74489
74665
  xhr.onload = function () {
74490
74666
 
74491
74667
  try {
74492
- if (xhr.readyState == 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
74668
+ if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
74493
74669
  return onerror.call(_this, file, xhr);
74494
74670
  }
74495
74671
  else {
@@ -74603,7 +74779,7 @@ Phaser.Loader.prototype = {
74603
74779
 
74604
74780
  xhr.onload = function () {
74605
74781
  try {
74606
- if (xhr.readyState == 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
74782
+ if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
74607
74783
  return onerror.call(_this, file, xhr);
74608
74784
  }
74609
74785
  else {
@@ -74811,11 +74987,11 @@ Phaser.Loader.prototype = {
74811
74987
  // Load the JSON or XML before carrying on with the next file
74812
74988
  loadNext = false;
74813
74989
 
74814
- if (file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_PYXEL)
74990
+ if (file.format === Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format === Phaser.Loader.TEXTURE_ATLAS_JSON_HASH || file.format === Phaser.Loader.TEXTURE_ATLAS_JSON_PYXEL)
74815
74991
  {
74816
74992
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
74817
74993
  }
74818
- else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
74994
+ else if (file.format === Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
74819
74995
  {
74820
74996
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.xmlLoadComplete);
74821
74997
  }
@@ -75999,7 +76175,7 @@ Phaser.Sound.prototype = {
75999
76175
  */
76000
76176
  loopFull: function (volume) {
76001
76177
 
76002
- this.play(null, 0, volume, true);
76178
+ return this.play(null, 0, volume, true);
76003
76179
 
76004
76180
  },
76005
76181
 
@@ -76056,6 +76232,8 @@ Phaser.Sound.prototype = {
76056
76232
  this._sound.pause();
76057
76233
  this._sound.currentTime = 0;
76058
76234
  }
76235
+
76236
+ this.isPlaying = false;
76059
76237
  }
76060
76238
 
76061
76239
  if (marker === '' && Object.keys(this.markers).length > 0)
@@ -76067,10 +76245,10 @@ Phaser.Sound.prototype = {
76067
76245
 
76068
76246
  if (marker !== '')
76069
76247
  {
76070
- this.currentMarker = marker;
76071
-
76072
76248
  if (this.markers[marker])
76073
76249
  {
76250
+ this.currentMarker = marker;
76251
+
76074
76252
  // Playing a marker? Then we default to the marker values
76075
76253
  this.position = this.markers[marker].start;
76076
76254
  this.volume = this.markers[marker].volume;
@@ -76095,7 +76273,7 @@ Phaser.Sound.prototype = {
76095
76273
  }
76096
76274
  else
76097
76275
  {
76098
- // console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist");
76276
+ console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist");
76099
76277
  return this;
76100
76278
  }
76101
76279
  }
@@ -76653,8 +76831,7 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", {
76653
76831
 
76654
76832
  /**
76655
76833
  * @name Phaser.Sound#volume
76656
- * @property {number} volume - Gets or sets the volume of this sound, a value between 0 and 1.
76657
- * @readonly
76834
+ * @property {number} volume - Gets or sets the volume of this sound, a value between 0 and 1. The value given is clamped to the range 0 to 1.
76658
76835
  */
76659
76836
  Object.defineProperty(Phaser.Sound.prototype, "volume", {
76660
76837
 
@@ -77767,6 +77944,18 @@ Phaser.ScaleManager = function (game, width, height) {
77767
77944
  */
77768
77945
  this.leaveIncorrectOrientation = new Phaser.Signal();
77769
77946
 
77947
+ /**
77948
+ * This boolean provides you with a way to determine if the browser is in Full Screen
77949
+ * mode (via the Full Screen API), and Phaser was the one responsible for activating it.
77950
+ *
77951
+ * It's possible that ScaleManager.isFullScreen returns `true` even if Phaser wasn't the
77952
+ * one that made the browser go full-screen, so this flag lets you determine that.
77953
+ *
77954
+ * @property {boolean} hasPhaserSetFullScreen
77955
+ * @default
77956
+ */
77957
+ this.hasPhaserSetFullScreen = false;
77958
+
77770
77959
  /**
77771
77960
  * If specified, this is the DOM element on which the Fullscreen API enter request will be invoked.
77772
77961
  * The target element must have the correct CSS styling and contain the Display canvas.
@@ -79307,9 +79496,11 @@ Phaser.ScaleManager.prototype = {
79307
79496
  {
79308
79497
  // Error is called in timeout to emulate the real fullscreenerror event better
79309
79498
  var _this = this;
79499
+
79310
79500
  setTimeout(function () {
79311
79501
  _this.fullScreenError();
79312
79502
  }, 10);
79503
+
79313
79504
  return;
79314
79505
  }
79315
79506
 
@@ -79326,7 +79517,7 @@ Phaser.ScaleManager.prototype = {
79326
79517
  }
79327
79518
  }
79328
79519
 
79329
- if (typeof antialias !== 'undefined' && this.game.renderType === Phaser.CANVAS)
79520
+ if (antialias !== undefined && this.game.renderType === Phaser.CANVAS)
79330
79521
  {
79331
79522
  this.game.stage.smoothed = antialias;
79332
79523
  }
@@ -79345,6 +79536,8 @@ Phaser.ScaleManager.prototype = {
79345
79536
  targetElement: fsTarget
79346
79537
  };
79347
79538
 
79539
+ this.hasPhaserSetFullScreen = true;
79540
+
79348
79541
  this.onFullScreenInit.dispatch(this, initData);
79349
79542
 
79350
79543
  if (this._createdFullScreenTarget)
@@ -79384,6 +79577,8 @@ Phaser.ScaleManager.prototype = {
79384
79577
  return false;
79385
79578
  }
79386
79579
 
79580
+ this.hasPhaserSetFullScreen = false;
79581
+
79387
79582
  document[this.game.device.cancelFullscreen]();
79388
79583
 
79389
79584
  return true;
@@ -79630,14 +79825,17 @@ Phaser.ScaleManager.prototype.constructor = Phaser.ScaleManager;
79630
79825
  Object.defineProperty(Phaser.ScaleManager.prototype, "boundingParent", {
79631
79826
 
79632
79827
  get: function () {
79828
+
79633
79829
  if (this.parentIsWindow ||
79634
- (this.isFullScreen && !this._createdFullScreenTarget))
79830
+ (this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget))
79635
79831
  {
79636
79832
  return null;
79637
79833
  }
79638
79834
 
79639
79835
  var parentNode = this.game.canvas && this.game.canvas.parentNode;
79836
+
79640
79837
  return parentNode || null;
79838
+
79641
79839
  }
79642
79840
 
79643
79841
  });
@@ -82051,7 +82249,7 @@ Phaser.LinkedList.prototype = {
82051
82249
  entity = entity.next;
82052
82250
 
82053
82251
  }
82054
- while(entity != this.last.next);
82252
+ while (entity !== this.last.next);
82055
82253
 
82056
82254
  }
82057
82255
 
@@ -83412,7 +83610,8 @@ Phaser.Color = {
83412
83610
  componentToHex: function (color) {
83413
83611
 
83414
83612
  var hex = color.toString(16);
83415
- return hex.length == 1 ? "0" + hex : hex;
83613
+
83614
+ return (hex.length === 1) ? '0' + hex : hex;
83416
83615
 
83417
83616
  },
83418
83617
 
@@ -85446,7 +85645,12 @@ Phaser.Physics.Arcade.prototype = {
85446
85645
  */
85447
85646
  separate: function (body1, body2, processCallback, callbackContext, overlapOnly) {
85448
85647
 
85449
- if (!body1.enable || !body2.enable || !this.intersects(body1, body2))
85648
+ if (
85649
+ !body1.enable ||
85650
+ !body2.enable ||
85651
+ body1.checkCollision.none ||
85652
+ body2.checkCollision.none ||
85653
+ !this.intersects(body1, body2))
85450
85654
  {
85451
85655
  return false;
85452
85656
  }
@@ -85652,7 +85856,10 @@ Phaser.Physics.Arcade.prototype = {
85652
85856
  this.getOverlapX(body1, body2);
85653
85857
  this.getOverlapY(body1, body2);
85654
85858
 
85655
- var angleCollision = this.angleBetweenCenters(body1, body2);
85859
+ var dx = body2.center.x - body1.center.x;
85860
+ var dy = body2.center.y - body1.center.y;
85861
+
85862
+ var angleCollision = Math.atan2(dy, dx);
85656
85863
 
85657
85864
  var overlap = 0;
85658
85865
 
@@ -86522,8 +86729,8 @@ Phaser.Physics.Arcade.prototype = {
86522
86729
  */
86523
86730
  angleBetweenCenters: function (source, target) {
86524
86731
 
86525
- var dx = target.center.x - source.center.x;
86526
- var dy = target.center.y - source.center.y;
86732
+ var dx = target.centerX - source.centerX;
86733
+ var dy = target.centerY - source.centerY;
86527
86734
 
86528
86735
  return Math.atan2(dy, dx);
86529
86736
 
@@ -86684,17 +86891,17 @@ Phaser.Physics.Arcade.Body = function (sprite) {
86684
86891
  this.allowRotation = true;
86685
86892
 
86686
86893
  /**
86687
- * An Arcade Physics Body can have angularVelocity and angularAcceleration. Please understand that the collision Body
86894
+ * The Body's rotation in degrees, as calculated by its angularVelocity and angularAcceleration. Please understand that the collision Body
86688
86895
  * itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation.
86689
86896
  * @property {number} rotation
86690
86897
  */
86691
- this.rotation = sprite.rotation;
86898
+ this.rotation = sprite.angle;
86692
86899
 
86693
86900
  /**
86694
86901
  * @property {number} preRotation - The previous rotation of the physics body.
86695
86902
  * @readonly
86696
86903
  */
86697
- this.preRotation = sprite.rotation;
86904
+ this.preRotation = sprite.angle;
86698
86905
 
86699
86906
  /**
86700
86907
  * @property {number} width - The calculated width of the physics body.
@@ -86858,25 +87065,25 @@ Phaser.Physics.Arcade.Body = function (sprite) {
86858
87065
  this.friction = new Phaser.Point(1, 0);
86859
87066
 
86860
87067
  /**
86861
- * @property {number} angularVelocity - The angular velocity controls the rotation speed of the Body. It is measured in radians per second.
87068
+ * @property {number} angularVelocity - The angular velocity controls the rotation speed of the Body. It is measured in degrees per second.
86862
87069
  * @default
86863
87070
  */
86864
87071
  this.angularVelocity = 0;
86865
87072
 
86866
87073
  /**
86867
- * @property {number} angularAcceleration - The angular acceleration is the rate of change of the angular velocity. Measured in radians per second squared.
87074
+ * @property {number} angularAcceleration - The angular acceleration is the rate of change of the angular velocity. Measured in degrees per second squared.
86868
87075
  * @default
86869
87076
  */
86870
87077
  this.angularAcceleration = 0;
86871
87078
 
86872
87079
  /**
86873
- * @property {number} angularDrag - The drag applied during the rotation of the Body.
87080
+ * @property {number} angularDrag - The drag applied during the rotation of the Body. Measured in degrees per second squared.
86874
87081
  * @default
86875
87082
  */
86876
87083
  this.angularDrag = 0;
86877
87084
 
86878
87085
  /**
86879
- * @property {number} maxAngular - The maximum angular velocity in radians per second that the Body can reach.
87086
+ * @property {number} maxAngular - The maximum angular velocity in degrees per second that the Body can reach.
86880
87087
  * @default
86881
87088
  */
86882
87089
  this.maxAngular = 1000;
@@ -86888,7 +87095,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
86888
87095
  this.mass = 1;
86889
87096
 
86890
87097
  /**
86891
- * @property {number} angle - The angle of the Body in radians, as calculated by its angularVelocity.
87098
+ * @property {number} angle - The angle of the Body's velocity in radians.
86892
87099
  * @readonly
86893
87100
  */
86894
87101
  this.angle = 0;
@@ -86969,6 +87176,8 @@ Phaser.Physics.Arcade.Body = function (sprite) {
86969
87176
  /**
86970
87177
  * Set the checkCollision properties to control which directions collision is processed for this Body.
86971
87178
  * For example checkCollision.up = false means it won't collide when the collision happened while moving up.
87179
+ * If you need to disable a Body entirely, use `body.enable = false`, this will also disable motion.
87180
+ * If you need to disable just collision and/or overlap checks, but retain motion, set `checkCollision.none = true`.
86972
87181
  * @property {object} checkCollision - An object containing allowed collision.
86973
87182
  */
86974
87183
  this.checkCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
@@ -87825,7 +88034,7 @@ Phaser.Physics.Arcade.Body.prototype = {
87825
88034
  /**
87826
88035
  * Returns true if the top of this Body is in contact with either the world bounds or a tile.
87827
88036
  *
87828
- * @method Phaser.Physics.Arcade.Body#onTop
88037
+ * @method Phaser.Physics.Arcade.Body#onCeiling
87829
88038
  * @return {boolean} True if in contact with either the world bounds or a tile.
87830
88039
  */
87831
88040
  onCeiling: function(){
@@ -89428,7 +89637,7 @@ Phaser.Physics.P2.prototype = {
89428
89637
  */
89429
89638
  removeBody: function (body) {
89430
89639
 
89431
- if (body.data.world == this.world)
89640
+ if (body.data.world === this.world)
89432
89641
  {
89433
89642
  this.world.removeBody(body.data);
89434
89643
 
@@ -94486,6 +94695,9 @@ Object.defineProperty(Phaser.Tile.prototype, "bottom", {
94486
94695
 
94487
94696
  /**
94488
94697
  * Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file.
94698
+ *
94699
+ * Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org
94700
+ *
94489
94701
  * To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key.
94490
94702
  * When using CSV data you must provide the key and the tileWidth and tileHeight parameters.
94491
94703
  * If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use `Tilemap.create` or pass the map and tile dimensions here.
@@ -94611,6 +94823,11 @@ Phaser.Tilemap = function (game, key, tileWidth, tileHeight, width, height) {
94611
94823
  */
94612
94824
  this.images = data.images;
94613
94825
 
94826
+ /**
94827
+ * @property {boolean} enableDebug - If set then console.log is used to dump out useful layer creation debug data.
94828
+ */
94829
+ this.enableDebug = false;
94830
+
94614
94831
  /**
94615
94832
  * @property {number} currentLayer - The current layer.
94616
94833
  */
@@ -95041,10 +95258,9 @@ Phaser.Tilemap.prototype = {
95041
95258
  * @param {number} [width] - The rendered width of the layer, should never be wider than Game.width. If not given it will be set to Game.width.
95042
95259
  * @param {number} [height] - The rendered height of the layer, should never be wider than Game.height. If not given it will be set to Game.height.
95043
95260
  * @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
95044
- * @param {boolean} [pixiTest] - Temporary additional flag to enable tests of the PIXI.Tilemap renderer
95045
95261
  * @return {Phaser.TilemapLayer} The TilemapLayer object. This is an extension of Phaser.Sprite and can be moved around the display list accordingly.
95046
95262
  */
95047
- createLayer: function (layer, width, height, group, pixiTest) {
95263
+ createLayer: function (layer, width, height, group) {
95048
95264
 
95049
95265
  // Add Buffer support for the left of the canvas
95050
95266
 
@@ -95065,15 +95281,46 @@ Phaser.Tilemap.prototype = {
95065
95281
  return;
95066
95282
  }
95067
95283
 
95068
- if ( pixiTest )
95284
+ // Sort out the display dimensions, so they never render too much, or too little.
95285
+
95286
+ if (width === undefined || width <= 0)
95287
+ {
95288
+ width = Math.min(this.game.width, this.layers[index].widthInPixels);
95289
+ }
95290
+ else if (width > this.game.width)
95291
+ {
95292
+ width = this.game.width;
95293
+ }
95294
+
95295
+ if (height === undefined || height <= 0)
95296
+ {
95297
+ height = Math.min(this.game.height, this.layers[index].heightInPixels);
95298
+ }
95299
+ else if (height > this.game.height)
95300
+ {
95301
+ height = this.game.height;
95302
+ }
95303
+
95304
+ if (this.enableDebug)
95069
95305
  {
95070
- return group.add(new Phaser.TilemapLayerGL(this.game, this, index, width, height));
95306
+ console.group('Tilemap.createLayer');
95307
+ console.log('Name:', this.layers[index].name);
95308
+ console.log('Size:', width, 'x', height);
95309
+ console.log('Tileset:', this.tilesets[0].name, 'index:', index);
95071
95310
  }
95072
95311
 
95073
- return group.add(new Phaser.TilemapLayer(this.game, this, index, width, height));
95312
+ var rootLayer = group.add(new Phaser.TilemapLayer(this.game, this, index, width, height));
95313
+
95314
+ if (this.enableDebug)
95315
+ {
95316
+ console.groupEnd();
95317
+ }
95318
+
95319
+ return rootLayer;
95074
95320
 
95075
95321
  },
95076
95322
 
95323
+
95077
95324
  /**
95078
95325
  * Creates a new and empty layer on this Tilemap. By default TilemapLayers are fixed to the camera.
95079
95326
  *
@@ -95092,7 +95339,7 @@ Phaser.Tilemap.prototype = {
95092
95339
 
95093
95340
  if (this.getLayerIndex(name) !== null)
95094
95341
  {
95095
- console.warn('Tilemap.createBlankLayer: Layer with matching name already exists');
95342
+ console.warn('Tilemap.createBlankLayer: Layer with matching name already exists: ' + name);
95096
95343
  return;
95097
95344
  }
95098
95345
 
@@ -95124,7 +95371,6 @@ Phaser.Tilemap.prototype = {
95124
95371
 
95125
95372
  for (var x = 0; x < width; x++)
95126
95373
  {
95127
- // row.push(null);
95128
95374
  row.push(new Phaser.Tile(layer, -1, x, y, tileWidth, tileHeight));
95129
95375
  }
95130
95376
 
@@ -95692,10 +95938,14 @@ Phaser.Tilemap.prototype = {
95692
95938
  hasTile: function (x, y, layer) {
95693
95939
 
95694
95940
  layer = this.getLayer(layer);
95695
- if (this.layers[layer].data[y] === undefined || this.layers[layer].data[y][x] === undefined) {
95941
+
95942
+ if (this.layers[layer].data[y] === undefined || this.layers[layer].data[y][x] === undefined)
95943
+ {
95696
95944
  return false;
95697
95945
  }
95946
+
95698
95947
  return (this.layers[layer].data[y][x].index > -1);
95948
+
95699
95949
  },
95700
95950
 
95701
95951
  /**
@@ -96671,7 +96921,7 @@ Phaser.TilemapLayer.ensureSharedCopyCanvas = function () {
96671
96921
 
96672
96922
  if (!this.sharedCopyCanvas)
96673
96923
  {
96674
- this.sharedCopyCanvas = Phaser.Canvas.create(2, 2);
96924
+ this.sharedCopyCanvas = PIXI.CanvasPool.create(this, 2, 2);
96675
96925
  }
96676
96926
 
96677
96927
  return this.sharedCopyCanvas;
@@ -97084,7 +97334,7 @@ Phaser.TilemapLayer.prototype.resolveTileset = function (tileIndex) {
97084
97334
 
97085
97335
  var setIndex = this.map.tiles[tileIndex] && this.map.tiles[tileIndex][2];
97086
97336
 
97087
- if (setIndex != null) // number: not null or undefined
97337
+ if (setIndex !== null)
97088
97338
  {
97089
97339
  var tileset = this.map.tilesets[setIndex];
97090
97340
 
@@ -97267,21 +97517,21 @@ Phaser.TilemapLayer.prototype.renderRegion = function (scrollX, scrollY, left, t
97267
97517
  // xmax/ymax - remaining cells to render on column/row
97268
97518
  var tx, ty, x, y, xmax, ymax;
97269
97519
 
97270
- for (y = normStartY, ymax = bottom - top, ty = baseY;
97271
- ymax >= 0;
97272
- y++, ymax--, ty += th)
97520
+ for (y = normStartY, ymax = bottom - top, ty = baseY; ymax >= 0; y++, ymax--, ty += th)
97273
97521
  {
97274
-
97275
- if (y >= height) { y -= height; }
97522
+ if (y >= height)
97523
+ {
97524
+ y -= height;
97525
+ }
97276
97526
 
97277
97527
  var row = this.layer.data[y];
97278
97528
 
97279
- for (x = normStartX, xmax = right - left, tx = baseX;
97280
- xmax >= 0;
97281
- x++, xmax--, tx += tw)
97529
+ for (x = normStartX, xmax = right - left, tx = baseX; xmax >= 0; x++, xmax--, tx += tw)
97282
97530
  {
97283
-
97284
- if (x >= width) { x -= width; }
97531
+ if (x >= width)
97532
+ {
97533
+ x -= width;
97534
+ }
97285
97535
 
97286
97536
  var tile = row[x];
97287
97537
 
@@ -97577,21 +97827,21 @@ Phaser.TilemapLayer.prototype.renderDebug = function () {
97577
97827
 
97578
97828
  context.strokeStyle = this.debugSettings.facingEdgeStroke;
97579
97829
 
97580
- for (y = normStartY, ymax = bottom - top, ty = baseY;
97581
- ymax >= 0;
97582
- y++, ymax--, ty += th)
97830
+ for (y = normStartY, ymax = bottom - top, ty = baseY; ymax >= 0; y++, ymax--, ty += th)
97583
97831
  {
97584
-
97585
- if (y >= height) { y -= height; }
97832
+ if (y >= height)
97833
+ {
97834
+ y -= height;
97835
+ }
97586
97836
 
97587
97837
  var row = this.layer.data[y];
97588
97838
 
97589
- for (x = normStartX, xmax = right - left, tx = baseX;
97590
- xmax >= 0;
97591
- x++, xmax--, tx += tw)
97839
+ for (x = normStartX, xmax = right - left, tx = baseX; xmax >= 0; x++, xmax--, tx += tw)
97592
97840
  {
97593
-
97594
- if (x >= width) { x -= width; }
97841
+ if (x >= width)
97842
+ {
97843
+ x -= width;
97844
+ }
97595
97845
 
97596
97846
  var tile = row[x];
97597
97847
  if (!tile || tile.index < 0 || !tile.collides)
@@ -97633,6 +97883,8 @@ Phaser.TilemapLayer.prototype.renderDebug = function () {
97633
97883
  context.lineTo(tx + this._mc.cw, ty + this._mc.ch);
97634
97884
  }
97635
97885
 
97886
+ context.closePath();
97887
+
97636
97888
  context.stroke();
97637
97889
  }
97638
97890
 
@@ -97769,34 +98021,7 @@ Phaser.TilemapParser = {
97769
98021
  INSERT_NULL: false,
97770
98022
 
97771
98023
  /**
97772
- * A tiled flag that resides within the 32 bit of the object gid and
97773
- * indicates whether the tiled/object is flipped horizontally.
97774
- *
97775
- * @constant
97776
- * @type {number}
97777
- */
97778
- FLIPPED_HORIZONTALLY_FLAG: 0x80000000,
97779
-
97780
- /**
97781
- * A tiled flag that resides within the 31 bit of the object gid and
97782
- * indicates whether the tiled/object is flipped vertically.
97783
- *
97784
- * @constant
97785
- * @type {number}
97786
- */
97787
- FLIPPED_VERTICALLY_FLAG: 0x40000000,
97788
-
97789
- /**
97790
- * A tiled flag that resides within the 30 bit of the object gid and
97791
- * indicates whether the tiled/object is flipped diagonally.
97792
- *
97793
- * @constant
97794
- * @type {number}
97795
- */
97796
- FLIPPED_DIAGONALLY_FLAG: 0x20000000,
97797
-
97798
- /**
97799
- * Parse tilemap data from the cache and creates a Tilemap object.
98024
+ * Parse tilemap data from the cache and creates data for a Tilemap object.
97800
98025
  *
97801
98026
  * @method Phaser.TilemapParser.parse
97802
98027
  * @param {Phaser.Game} game - Game reference to the currently running game.
@@ -97910,58 +98135,41 @@ Phaser.TilemapParser = {
97910
98135
  */
97911
98136
  getEmptyData: function (tileWidth, tileHeight, width, height) {
97912
98137
 
97913
- var map = {};
97914
-
97915
- map.width = 0;
97916
- map.height = 0;
97917
- map.tileWidth = 0;
97918
- map.tileHeight = 0;
97919
-
97920
- if (typeof tileWidth !== 'undefined' && tileWidth !== null) { map.tileWidth = tileWidth; }
97921
- if (typeof tileHeight !== 'undefined' && tileHeight !== null) { map.tileHeight = tileHeight; }
97922
- if (typeof width !== 'undefined' && width !== null) { map.width = width; }
97923
- if (typeof height !== 'undefined' && height !== null) { map.height = height; }
97924
-
97925
- map.orientation = 'orthogonal';
97926
- map.version = '1';
97927
- map.properties = {};
97928
- map.widthInPixels = 0;
97929
- map.heightInPixels = 0;
97930
-
97931
- var layers = [];
97932
-
97933
- var layer = {
97934
-
97935
- name: 'layer',
97936
- x: 0,
97937
- y: 0,
97938
- width: 0,
97939
- height: 0,
98138
+ return {
98139
+ width: (width !== undefined && width !== null) ? width : 0,
98140
+ height: (height !== undefined && height !== null) ? height : 0,
98141
+ tileWidth: (tileWidth !== undefined && tileWidth !== null) ? tileWidth : 0,
98142
+ tileHeight: (tileHeight !== undefined && tileHeight !== null) ? tileHeight : 0,
98143
+ orientation: 'orthogonal',
98144
+ version: '1',
98145
+ properties: {},
97940
98146
  widthInPixels: 0,
97941
98147
  heightInPixels: 0,
97942
- alpha: 1,
97943
- visible: true,
97944
- properties: {},
97945
- indexes: [],
97946
- callbacks: [],
97947
- bodies: [],
97948
- data: []
97949
-
98148
+ layers: [
98149
+ {
98150
+ name: 'layer',
98151
+ x: 0,
98152
+ y: 0,
98153
+ width: 0,
98154
+ height: 0,
98155
+ widthInPixels: 0,
98156
+ heightInPixels: 0,
98157
+ alpha: 1,
98158
+ visible: true,
98159
+ properties: {},
98160
+ indexes: [],
98161
+ callbacks: [],
98162
+ bodies: [],
98163
+ data: []
98164
+ }
98165
+ ],
98166
+ images: [],
98167
+ objects: {},
98168
+ collision: {},
98169
+ tilesets: [],
98170
+ tiles: []
97950
98171
  };
97951
98172
 
97952
- // fill with nulls?
97953
-
97954
- layers.push(layer);
97955
-
97956
- map.layers = layers;
97957
- map.images = [];
97958
- map.objects = {};
97959
- map.collision = {};
97960
- map.tilesets = [];
97961
- map.tiles = [];
97962
-
97963
- return map;
97964
-
97965
98173
  },
97966
98174
 
97967
98175
  /**
@@ -97979,18 +98187,18 @@ Phaser.TilemapParser = {
97979
98187
  }
97980
98188
 
97981
98189
  // Map data will consist of: layers, objects, images, tilesets, sizes
97982
- var map = {};
97983
-
97984
- map.width = json.width;
97985
- map.height = json.height;
97986
- map.tileWidth = json.tilewidth;
97987
- map.tileHeight = json.tileheight;
97988
- map.orientation = json.orientation;
97989
- map.format = Phaser.Tilemap.TILED_JSON;
97990
- map.version = json.version;
97991
- map.properties = json.properties;
97992
- map.widthInPixels = map.width * map.tileWidth;
97993
- map.heightInPixels = map.height * map.tileHeight;
98190
+ var map = {
98191
+ width: json.width,
98192
+ height: json.height,
98193
+ tileWidth: json.tilewidth,
98194
+ tileHeight: json.tileheight,
98195
+ orientation: json.orientation,
98196
+ format: Phaser.Tilemap.TILED_JSON,
98197
+ version: json.version,
98198
+ properties: json.properties,
98199
+ widthInPixels: json.width * json.tilewidth,
98200
+ heightInPixels: json.height * json.tileheight
98201
+ };
97994
98202
 
97995
98203
  // Tile Layers
97996
98204
  var layers = [];
@@ -98006,27 +98214,35 @@ Phaser.TilemapParser = {
98006
98214
 
98007
98215
  // Base64 decode data if necessary
98008
98216
  // NOTE: uncompressed base64 only.
98009
- if (!curl.compression && curl.encoding && curl.encoding === "base64") {
98010
- var binaryString = window.atob(curl.data);
98217
+
98218
+ if (!curl.compression && curl.encoding && curl.encoding === 'base64')
98219
+ {
98220
+ var binaryString = window.atob(curl.data);
98011
98221
  var len = binaryString.length;
98012
- var bytes = new Array( len );
98222
+ var bytes = new Array(len);
98223
+
98013
98224
  // Interpret binaryString as an array of bytes representing
98014
98225
  // little-endian encoded uint32 values.
98015
- for (var j = 0; j < len; j+=4) {
98016
- bytes[j/4] = (binaryString.charCodeAt(j) |
98017
- binaryString.charCodeAt(j+1) << 8 |
98018
- binaryString.charCodeAt(j+2) << 16 |
98019
- binaryString.charCodeAt(j+3) << 24) >>> 0;
98226
+ for (var j = 0; j < len; j+=4)
98227
+ {
98228
+ bytes[j / 4] = (
98229
+ binaryString.charCodeAt(j) |
98230
+ binaryString.charCodeAt(j + 1) << 8 |
98231
+ binaryString.charCodeAt(j + 2) << 16 |
98232
+ binaryString.charCodeAt(j + 3) << 24
98233
+ ) >>> 0;
98020
98234
  }
98235
+
98021
98236
  curl.data = bytes;
98237
+
98022
98238
  delete curl.encoding;
98023
98239
  }
98024
- else if(curl.compression){
98240
+ else if (curl.compression)
98241
+ {
98025
98242
  console.warn('TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + curl.name + '\'');
98026
98243
  continue;
98027
98244
  }
98028
98245
 
98029
-
98030
98246
  var layer = {
98031
98247
 
98032
98248
  name: curl.name,
@@ -98066,12 +98282,11 @@ Phaser.TilemapParser = {
98066
98282
  rotation = 0;
98067
98283
  flipped = false;
98068
98284
  gid = curl.data[t];
98285
+ flippedVal = 0;
98069
98286
 
98070
98287
  // If true the current tile is flipped or rotated (Tiled TMX format)
98071
98288
  if (gid > 0x20000000)
98072
98289
  {
98073
- flippedVal = 0;
98074
-
98075
98290
  // FlippedX
98076
98291
  if (gid > 0x80000000)
98077
98292
  {
@@ -98086,7 +98301,7 @@ Phaser.TilemapParser = {
98086
98301
  flippedVal += 2;
98087
98302
  }
98088
98303
 
98089
- // FlippedAD
98304
+ // FlippedAD (anti-diagonal = top-right is swapped with bottom-left corners)
98090
98305
  if (gid > 0x20000000)
98091
98306
  {
98092
98307
  gid -= 0x20000000;
@@ -98096,28 +98311,34 @@ Phaser.TilemapParser = {
98096
98311
  switch (flippedVal)
98097
98312
  {
98098
98313
  case 5:
98099
- rotation = Math.PI/2;
98314
+ rotation = Math.PI / 2;
98100
98315
  break;
98316
+
98101
98317
  case 6:
98102
98318
  rotation = Math.PI;
98103
98319
  break;
98320
+
98104
98321
  case 3:
98105
- rotation = 3*Math.PI/2;
98322
+ rotation = 3 * Math.PI / 2;
98106
98323
  break;
98324
+
98107
98325
  case 4:
98108
98326
  rotation = 0;
98109
98327
  flipped = true;
98110
98328
  break;
98329
+
98111
98330
  case 7:
98112
- rotation = Math.PI/2;
98331
+ rotation = Math.PI / 2;
98113
98332
  flipped = true;
98114
98333
  break;
98334
+
98115
98335
  case 2:
98116
98336
  rotation = Math.PI;
98117
98337
  flipped = true;
98118
98338
  break;
98339
+
98119
98340
  case 1:
98120
- rotation = 3*Math.PI/2;
98341
+ rotation = 3 * Math.PI / 2;
98121
98342
  flipped = true;
98122
98343
  break;
98123
98344
  }
@@ -98126,9 +98347,18 @@ Phaser.TilemapParser = {
98126
98347
  // index, x, y, width, height
98127
98348
  if (gid > 0)
98128
98349
  {
98129
- row.push(new Phaser.Tile(layer, gid, x, output.length, json.tilewidth, json.tileheight));
98130
- row[row.length - 1].rotation = rotation;
98131
- row[row.length - 1].flipped = flipped;
98350
+ var tile = new Phaser.Tile(layer, gid, x, output.length, json.tilewidth, json.tileheight);
98351
+
98352
+ tile.rotation = rotation;
98353
+ tile.flipped = flipped;
98354
+
98355
+ if (flippedVal !== 0)
98356
+ {
98357
+ // The WebGL renderer uses this to flip UV coordinates before drawing
98358
+ tile.flippedVal = flippedVal;
98359
+ }
98360
+
98361
+ row.push(tile);
98132
98362
  }
98133
98363
  else
98134
98364
  {
@@ -98155,7 +98385,6 @@ Phaser.TilemapParser = {
98155
98385
  layer.data = output;
98156
98386
 
98157
98387
  layers.push(layer);
98158
-
98159
98388
  }
98160
98389
 
98161
98390
  map.layers = layers;
@@ -98198,6 +98427,7 @@ Phaser.TilemapParser = {
98198
98427
  // Tilesets & Image Collections
98199
98428
  var tilesets = [];
98200
98429
  var imagecollections = [];
98430
+ var lastSet = null;
98201
98431
 
98202
98432
  for (var i = 0; i < json.tilesets.length; i++)
98203
98433
  {
@@ -98216,6 +98446,7 @@ Phaser.TilemapParser = {
98216
98446
  // For a normal sliced tileset the row/count/size information is computed when updated.
98217
98447
  // This is done (again) after the image is set.
98218
98448
  newSet.updateTileData(set.imagewidth, set.imageheight);
98449
+
98219
98450
  tilesets.push(newSet);
98220
98451
  }
98221
98452
  else
@@ -98232,6 +98463,13 @@ Phaser.TilemapParser = {
98232
98463
  imagecollections.push(newCollection);
98233
98464
  }
98234
98465
 
98466
+ // We've got a new Tileset, so set the lastgid into the previous one
98467
+ if (lastSet)
98468
+ {
98469
+ lastSet.lastgid = set.firstgid - 1;
98470
+ }
98471
+
98472
+ lastSet = set;
98235
98473
  }
98236
98474
 
98237
98475
  map.tilesets = tilesets;
@@ -98275,8 +98513,6 @@ Phaser.TilemapParser = {
98275
98513
  // Object Tiles
98276
98514
  if (curo.objects[v].gid)
98277
98515
  {
98278
- var self = this;
98279
-
98280
98516
  var object = {
98281
98517
 
98282
98518
  gid: curo.objects[v].gid,
@@ -98284,13 +98520,9 @@ Phaser.TilemapParser = {
98284
98520
  type: curo.objects[v].hasOwnProperty("type") ? curo.objects[v].type : "",
98285
98521
  x: curo.objects[v].x,
98286
98522
  y: curo.objects[v].y,
98287
- width: curo.objects[v].width,
98288
- height: curo.objects[v].height,
98289
98523
  visible: curo.objects[v].visible,
98290
- properties: curo.objects[v].properties,
98291
- horizontallyFlipped: curo.objects[v].gid & self.FLIPPED_HORIZONTALLY_FLAG,
98292
- verticallyFlipped: curo.objects[v].gid & self.FLIPPED_VERTICALLY_FLAG,
98293
- diagonallyFlipped: curo.objects[v].gid & self.FLIPPED_DIAGONALLY_FLAG
98524
+ properties: curo.objects[v].properties
98525
+
98294
98526
  };
98295
98527
 
98296
98528
  if (curo.objects[v].rotation)
@@ -98334,15 +98566,14 @@ Phaser.TilemapParser = {
98334
98566
  // polygon
98335
98567
  else if (curo.objects[v].polygon)
98336
98568
  {
98337
- var object = slice(curo.objects[v],
98338
- ["name", "type", "x", "y", "visible", "rotation", "properties" ]);
98569
+ var object = slice(curo.objects[v], ['name', 'type', 'x', 'y', 'visible', 'rotation', 'properties']);
98339
98570
 
98340
98571
  // Parse the polygon into an array
98341
98572
  object.polygon = [];
98342
98573
 
98343
98574
  for (var p = 0; p < curo.objects[v].polygon.length; p++)
98344
98575
  {
98345
- object.polygon.push([ curo.objects[v].polygon[p].x, curo.objects[v].polygon[p].y ]);
98576
+ object.polygon.push([curo.objects[v].polygon[p].x, curo.objects[v].polygon[p].y]);
98346
98577
  }
98347
98578
 
98348
98579
  objects[curo.name].push(object);
@@ -98351,15 +98582,13 @@ Phaser.TilemapParser = {
98351
98582
  // ellipse
98352
98583
  else if (curo.objects[v].ellipse)
98353
98584
  {
98354
- var object = slice(curo.objects[v],
98355
- ["name", "type", "ellipse", "x", "y", "width", "height", "visible", "rotation", "properties" ]);
98585
+ var object = slice(curo.objects[v], ['name', 'type', 'ellipse', 'x', 'y', 'width', 'height', 'visible', 'rotation', 'properties']);
98356
98586
  objects[curo.name].push(object);
98357
98587
  }
98358
98588
  // otherwise it's a rectangle
98359
98589
  else
98360
98590
  {
98361
- var object = slice(curo.objects[v],
98362
- ["name", "type", "x", "y", "width", "height", "visible", "rotation", "properties" ]);
98591
+ var object = slice(curo.objects[v], ['name', 'type', 'x', 'y', 'width', 'height', 'visible', 'rotation', 'properties']);
98363
98592
  object.rectangle = true;
98364
98593
  objects[curo.name].push(object);
98365
98594
  }
@@ -98423,11 +98652,13 @@ Phaser.TilemapParser = {
98423
98652
  var sid;
98424
98653
  var set;
98425
98654
 
98426
- // go through each of the map layers
98655
+ // go through each of the map data layers
98427
98656
  for (var i = 0; i < map.layers.length; i++)
98428
98657
  {
98429
98658
  layer = map.layers[i];
98430
98659
 
98660
+ set = null;
98661
+
98431
98662
  // rows of tiles
98432
98663
  for (var j = 0; j < layer.data.length; j++)
98433
98664
  {
@@ -98448,12 +98679,14 @@ Phaser.TilemapParser = {
98448
98679
  sid = map.tiles[tile.index][2];
98449
98680
  set = map.tilesets[sid];
98450
98681
 
98682
+
98451
98683
  // if that tile type has any properties, add them to the tile object
98452
98684
 
98453
98685
  if (set.tileProperties && set.tileProperties[tile.index - set.firstgid])
98454
98686
  {
98455
98687
  tile.properties = Phaser.Utils.mixin(set.tileProperties[tile.index - set.firstgid], tile.properties);
98456
98688
  }
98689
+
98457
98690
  }
98458
98691
  }
98459
98692
  }
@@ -100355,6 +100588,14 @@ Phaser.Weapon = function (game, parent) {
100355
100588
  */
100356
100589
  this._nextFire = 0;
100357
100590
 
100591
+ /**
100592
+ * Internal firing rotation tracking point.
100593
+ *
100594
+ * @type {Phaser.Point}
100595
+ * @private
100596
+ */
100597
+ this._rotatedPoint = new Phaser.Point();
100598
+
100358
100599
  };
100359
100600
 
100360
100601
  Phaser.Weapon.prototype = Object.create(Phaser.Plugin.prototype);
@@ -100596,7 +100837,7 @@ Phaser.Weapon.prototype.update = function () {
100596
100837
  }
100597
100838
  }
100598
100839
 
100599
- if (this.autofire && this.game.time.now < this._nextFire)
100840
+ if (this.autofire)
100600
100841
  {
100601
100842
  this.fire();
100602
100843
  }
@@ -100687,7 +100928,7 @@ Phaser.Weapon.prototype.trackPointer = function (pointer, offsetX, offsetY) {
100687
100928
  * @param {Phaser.Sprite|Phaser.Point|Object} [from] - Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides `Weapon.trackedSprite` or `trackedPointer`. Pass `null` to ignore it.
100688
100929
  * @param {number} [x] - The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
100689
100930
  * @param {number} [y] - The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
100690
- * @return {boolean} True if a bullet was successfully fired, otherwise false.
100931
+ * @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
100691
100932
  */
100692
100933
  Phaser.Weapon.prototype.fire = function (from, x, y) {
100693
100934
 
@@ -100718,14 +100959,32 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
100718
100959
  }
100719
100960
  else if (this.trackedSprite)
100720
100961
  {
100721
- if (this.fireFrom.width > 1)
100962
+ if (this.trackRotation)
100722
100963
  {
100723
- this.fireFrom.centerOn(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
100964
+ this._rotatedPoint.set(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
100965
+ this._rotatedPoint.rotate(this.trackedSprite.world.x, this.trackedSprite.world.y, this.trackedSprite.rotation);
100966
+
100967
+ if (this.fireFrom.width > 1)
100968
+ {
100969
+ this.fireFrom.centerOn(this._rotatedPoint.x, this._rotatedPoint.y);
100970
+ }
100971
+ else
100972
+ {
100973
+ this.fireFrom.x = this._rotatedPoint.x;
100974
+ this.fireFrom.y = this._rotatedPoint.y;
100975
+ }
100724
100976
  }
100725
100977
  else
100726
100978
  {
100727
- this.fireFrom.x = this.trackedSprite.world.x + this.trackOffset.x;
100728
- this.fireFrom.y = this.trackedSprite.world.y + this.trackOffset.y;
100979
+ if (this.fireFrom.width > 1)
100980
+ {
100981
+ this.fireFrom.centerOn(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
100982
+ }
100983
+ else
100984
+ {
100985
+ this.fireFrom.x = this.trackedSprite.world.x + this.trackOffset.x;
100986
+ this.fireFrom.y = this.trackedSprite.world.y + this.trackOffset.y;
100987
+ }
100729
100988
  }
100730
100989
 
100731
100990
  if (this.bulletInheritSpriteSpeed)
@@ -100857,7 +101116,23 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
100857
101116
  bullet.body.velocity.set(moveX, moveY);
100858
101117
  bullet.body.gravity.set(this.bulletGravity.x, this.bulletGravity.y);
100859
101118
 
100860
- this._nextFire = this.game.time.now + this.fireRate;
101119
+ if (this.bulletSpeedVariance !== 0)
101120
+ {
101121
+ var rate = this.fireRate;
101122
+
101123
+ rate += Phaser.Math.between(-this.fireRateVariance, this.fireRateVariance);
101124
+
101125
+ if (rate < 0)
101126
+ {
101127
+ rate = 0;
101128
+ }
101129
+
101130
+ this._nextFire = this.game.time.now + rate;
101131
+ }
101132
+ else
101133
+ {
101134
+ this._nextFire = this.game.time.now + this.fireRate;
101135
+ }
100861
101136
 
100862
101137
  this.shots++;
100863
101138
 
@@ -100867,9 +101142,8 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
100867
101142
  {
100868
101143
  this.onFireLimit.dispatch(this, this.fireLimit);
100869
101144
  }
100870
-
100871
101145
  }
100872
-
101146
+ return bullet;
100873
101147
  };
100874
101148
 
100875
101149
  /**
@@ -100878,7 +101152,7 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
100878
101152
  *
100879
101153
  * @method Phaser.Weapon#fireAtPointer
100880
101154
  * @param {Phaser.Pointer} [pointer] - The Pointer to fire the bullet towards.
100881
- * @return {boolean} True if a bullet was successfully fired, otherwise false.
101155
+ * @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
100882
101156
  */
100883
101157
  Phaser.Weapon.prototype.fireAtPointer = function (pointer) {
100884
101158
 
@@ -100894,7 +101168,7 @@ Phaser.Weapon.prototype.fireAtPointer = function (pointer) {
100894
101168
  *
100895
101169
  * @method Phaser.Weapon#fireAtSprite
100896
101170
  * @param {Phaser.Sprite} [sprite] - The Sprite to fire the bullet towards.
100897
- * @return {boolean} True if a bullet was successfully fired, otherwise false.
101171
+ * @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
100898
101172
  */
100899
101173
  Phaser.Weapon.prototype.fireAtSprite = function (sprite) {
100900
101174
 
@@ -100909,7 +101183,7 @@ Phaser.Weapon.prototype.fireAtSprite = function (sprite) {
100909
101183
  * @method Phaser.Weapon#fireAtXY
100910
101184
  * @param {number} [x] - The x coordinate, in world space, to fire the bullet towards.
100911
101185
  * @param {number} [y] - The y coordinate, in world space, to fire the bullet towards.
100912
- * @return {boolean} True if a bullet was successfully fired, otherwise false.
101186
+ * @return {Phaser.Bullet} The fired bullet if successful, null otherwise.
100913
101187
  */
100914
101188
  Phaser.Weapon.prototype.fireAtXY = function (x, y) {
100915
101189