phaser-rails 2.5.0.0 → 2.6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phaser/rails/version.rb +1 -1
- data/vendor/assets/javascripts/phaser.js +2128 -1073
- data/vendor/assets/javascripts/phaser.map +1 -1
- data/vendor/assets/javascripts/phaser.min.js +26 -26
- metadata +2 -2
@@ -7,7 +7,7 @@
|
|
7
7
|
*
|
8
8
|
* Phaser - http://phaser.io
|
9
9
|
*
|
10
|
-
* v2.
|
10
|
+
* v2.6.0 "Fal Moran" - Built: Fri Jul 08 2016 15:53:06
|
11
11
|
*
|
12
12
|
* By Richard Davey http://www.photonstorm.com @photonstorm
|
13
13
|
*
|
@@ -13768,64 +13768,91 @@ PIXI.defaultRenderOptions = {
|
|
13768
13768
|
*/
|
13769
13769
|
|
13770
13770
|
/**
|
13771
|
-
|
13772
|
-
|
13771
|
+
* @author Mat Groves http://matgroves.com @Doormat23
|
13772
|
+
* @author Richard Davey <rich@photonstorm.com>
|
13773
|
+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
13774
|
+
*/
|
13773
13775
|
|
13774
13776
|
/**
|
13775
|
-
|
13776
|
-
|
13777
|
-
|
13778
|
-
|
13779
|
-
|
13780
|
-
|
13781
|
-
|
13782
|
-
|
13777
|
+
* The base class for all objects that are rendered. Contains properties for position, scaling,
|
13778
|
+
* rotation, masks and cache handling.
|
13779
|
+
*
|
13780
|
+
* This is an abstract class and should not be used on its own, rather it should be extended.
|
13781
|
+
*
|
13782
|
+
* It is used internally by the likes of PIXI.Sprite.
|
13783
|
+
*
|
13784
|
+
* @class PIXI.DisplayObject
|
13785
|
+
* @constructor
|
13786
|
+
*/
|
13787
|
+
PIXI.DisplayObject = function() {
|
13788
|
+
|
13783
13789
|
/**
|
13784
|
-
|
13785
|
-
|
13786
|
-
|
13787
|
-
|
13788
|
-
|
13790
|
+
* The coordinates, in pixels, of this DisplayObject, relative to its parent container.
|
13791
|
+
*
|
13792
|
+
* The value of this property does not reflect any positioning happening further up the display list.
|
13793
|
+
* To obtain that value please see the `worldPosition` property.
|
13794
|
+
*
|
13795
|
+
* @property {PIXI.Point} position
|
13796
|
+
* @default
|
13797
|
+
*/
|
13789
13798
|
this.position = new PIXI.Point(0, 0);
|
13790
13799
|
|
13791
13800
|
/**
|
13792
|
-
|
13793
|
-
|
13794
|
-
|
13795
|
-
|
13796
|
-
|
13801
|
+
* The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject
|
13802
|
+
* at its default size. A value of 0.5 would scale this DisplayObject by half, and so on.
|
13803
|
+
*
|
13804
|
+
* The value of this property does not reflect any scaling happening further up the display list.
|
13805
|
+
* To obtain that value please see the `worldScale` property.
|
13806
|
+
*
|
13807
|
+
* @property {PIXI.Point} scale
|
13808
|
+
* @default
|
13809
|
+
*/
|
13797
13810
|
this.scale = new PIXI.Point(1, 1);
|
13798
13811
|
|
13799
13812
|
/**
|
13800
|
-
|
13801
|
-
|
13802
|
-
|
13803
|
-
|
13804
|
-
|
13813
|
+
* The pivot point of this DisplayObject that it rotates around. The values are expressed
|
13814
|
+
* in pixel values.
|
13815
|
+
* @property {PIXI.Point} pivot
|
13816
|
+
* @default
|
13817
|
+
*/
|
13805
13818
|
this.pivot = new PIXI.Point(0, 0);
|
13806
13819
|
|
13807
13820
|
/**
|
13808
|
-
|
13809
|
-
|
13810
|
-
|
13811
|
-
|
13812
|
-
|
13821
|
+
* The rotation of this DisplayObject. The value is given, and expressed, in radians, and is based on
|
13822
|
+
* a right-handed orientation.
|
13823
|
+
*
|
13824
|
+
* The value of this property does not reflect any rotation happening further up the display list.
|
13825
|
+
* To obtain that value please see the `worldRotation` property.
|
13826
|
+
*
|
13827
|
+
* @property {number} rotation
|
13828
|
+
* @default
|
13829
|
+
*/
|
13813
13830
|
this.rotation = 0;
|
13814
13831
|
|
13815
13832
|
/**
|
13816
|
-
|
13817
|
-
|
13818
|
-
|
13819
|
-
|
13820
|
-
|
13833
|
+
* The alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
|
13834
|
+
* Please note that an object with an alpha value of 0 is skipped during the render pass.
|
13835
|
+
*
|
13836
|
+
* The value of this property does not reflect any alpha values set further up the display list.
|
13837
|
+
* To obtain that value please see the `worldAlpha` property.
|
13838
|
+
*
|
13839
|
+
* @property {number} alpha
|
13840
|
+
* @default
|
13841
|
+
*/
|
13821
13842
|
this.alpha = 1;
|
13822
13843
|
|
13823
13844
|
/**
|
13824
|
-
|
13825
|
-
|
13826
|
-
|
13827
|
-
|
13828
|
-
|
13845
|
+
* The visibility of this DisplayObject. A value of `false` makes the object invisible.
|
13846
|
+
* A value of `true` makes it visible. Please note that an object with a visible value of
|
13847
|
+
* `false` is skipped during the render pass. Equally a DisplayObject with visible false will
|
13848
|
+
* not render any of its children.
|
13849
|
+
*
|
13850
|
+
* The value of this property does not reflect any visible values set further up the display list.
|
13851
|
+
* To obtain that value please see the `worldVisible` property.
|
13852
|
+
*
|
13853
|
+
* @property {boolean} visible
|
13854
|
+
* @default
|
13855
|
+
*/
|
13829
13856
|
this.visible = true;
|
13830
13857
|
|
13831
13858
|
/**
|
@@ -13838,688 +13865,729 @@ PIXI.DisplayObject = function()
|
|
13838
13865
|
this.hitArea = null;
|
13839
13866
|
|
13840
13867
|
/**
|
13841
|
-
|
13842
|
-
|
13843
|
-
|
13844
|
-
|
13845
|
-
|
13868
|
+
* Should this DisplayObject be rendered by the renderer? An object with a renderable value of
|
13869
|
+
* `false` is skipped during the render pass.
|
13870
|
+
*
|
13871
|
+
* @property {boolean} renderable
|
13872
|
+
* @default
|
13873
|
+
*/
|
13846
13874
|
this.renderable = false;
|
13847
13875
|
|
13848
13876
|
/**
|
13849
|
-
|
13850
|
-
|
13851
|
-
|
13852
|
-
|
13853
|
-
|
13854
|
-
|
13877
|
+
* The parent DisplayObjectContainer that this DisplayObject is a child of.
|
13878
|
+
* All DisplayObjects must belong to a parent in order to be rendered.
|
13879
|
+
* The root parent is the Stage object. This property is set automatically when the
|
13880
|
+
* DisplayObject is added to, or removed from, a DisplayObjectContainer.
|
13881
|
+
*
|
13882
|
+
* @property {PIXI.DisplayObjectContainer} parent
|
13883
|
+
* @default
|
13884
|
+
* @readOnly
|
13885
|
+
*/
|
13855
13886
|
this.parent = null;
|
13856
13887
|
|
13857
13888
|
/**
|
13858
|
-
|
13859
|
-
|
13860
|
-
|
13861
|
-
|
13862
|
-
|
13863
|
-
|
13889
|
+
* The stage that this DisplayObject is connected to.
|
13890
|
+
*
|
13891
|
+
* @property {PIXI.Stage} stage
|
13892
|
+
* @default
|
13893
|
+
* @readOnly
|
13894
|
+
*/
|
13864
13895
|
this.stage = null;
|
13865
13896
|
|
13866
13897
|
/**
|
13867
|
-
|
13868
|
-
|
13869
|
-
|
13870
|
-
|
13871
|
-
|
13872
|
-
|
13898
|
+
* The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
|
13899
|
+
* This value is the calculated total, based on the alpha values of all parents of this DisplayObjects
|
13900
|
+
* in the display list.
|
13901
|
+
*
|
13902
|
+
* To obtain, and set, the local alpha value, see the `alpha` property.
|
13903
|
+
*
|
13904
|
+
* Note: This property is only updated at the end of the `updateTransform` call, once per render. Until
|
13905
|
+
* that happens this property will contain values based on the previous frame. Be mindful of this if
|
13906
|
+
* accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.
|
13907
|
+
*
|
13908
|
+
* @property {number} worldAlpha
|
13909
|
+
* @readOnly
|
13910
|
+
*/
|
13873
13911
|
this.worldAlpha = 1;
|
13874
13912
|
|
13875
13913
|
/**
|
13876
|
-
|
13877
|
-
|
13878
|
-
|
13879
|
-
|
13880
|
-
|
13881
|
-
|
13882
|
-
|
13914
|
+
* The current transform of this DisplayObject.
|
13915
|
+
*
|
13916
|
+
* This property contains the calculated total, based on the transforms of all parents of this
|
13917
|
+
* DisplayObject in the display list.
|
13918
|
+
*
|
13919
|
+
* Note: This property is only updated at the end of the `updateTransform` call, once per render. Until
|
13920
|
+
* that happens this property will contain values based on the previous frame. Be mindful of this if
|
13921
|
+
* accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.
|
13922
|
+
*
|
13923
|
+
* @property {PIXI.Matrix} worldTransform
|
13924
|
+
* @readOnly
|
13925
|
+
*/
|
13883
13926
|
this.worldTransform = new PIXI.Matrix();
|
13884
13927
|
|
13885
13928
|
/**
|
13886
|
-
|
13887
|
-
|
13888
|
-
|
13889
|
-
|
13890
|
-
|
13891
|
-
|
13892
|
-
|
13929
|
+
* The coordinates, in pixels, of this DisplayObject within the world.
|
13930
|
+
*
|
13931
|
+
* This property contains the calculated total, based on the positions of all parents of this
|
13932
|
+
* DisplayObject in the display list.
|
13933
|
+
*
|
13934
|
+
* Note: This property is only updated at the end of the `updateTransform` call, once per render. Until
|
13935
|
+
* that happens this property will contain values based on the previous frame. Be mindful of this if
|
13936
|
+
* accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.
|
13937
|
+
*
|
13938
|
+
* @property {PIXI.Point} worldPosition
|
13939
|
+
* @readOnly
|
13940
|
+
*/
|
13893
13941
|
this.worldPosition = new PIXI.Point(0, 0);
|
13894
13942
|
|
13895
13943
|
/**
|
13896
|
-
|
13897
|
-
|
13898
|
-
|
13899
|
-
|
13900
|
-
|
13901
|
-
|
13902
|
-
|
13944
|
+
* The global scale of this DisplayObject.
|
13945
|
+
*
|
13946
|
+
* This property contains the calculated total, based on the scales of all parents of this
|
13947
|
+
* DisplayObject in the display list.
|
13948
|
+
*
|
13949
|
+
* Note: This property is only updated at the end of the `updateTransform` call, once per render. Until
|
13950
|
+
* that happens this property will contain values based on the previous frame. Be mindful of this if
|
13951
|
+
* accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.
|
13952
|
+
*
|
13953
|
+
* @property {PIXI.Point} worldScale
|
13954
|
+
* @readOnly
|
13955
|
+
*/
|
13903
13956
|
this.worldScale = new PIXI.Point(1, 1);
|
13904
13957
|
|
13905
13958
|
/**
|
13906
|
-
|
13907
|
-
|
13908
|
-
|
13909
|
-
|
13910
|
-
|
13911
|
-
|
13912
|
-
|
13959
|
+
* The rotation, in radians, of this DisplayObject.
|
13960
|
+
*
|
13961
|
+
* This property contains the calculated total, based on the rotations of all parents of this
|
13962
|
+
* DisplayObject in the display list.
|
13963
|
+
*
|
13964
|
+
* Note: This property is only updated at the end of the `updateTransform` call, once per render. Until
|
13965
|
+
* that happens this property will contain values based on the previous frame. Be mindful of this if
|
13966
|
+
* accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.
|
13967
|
+
*
|
13968
|
+
* @property {number} worldRotation
|
13969
|
+
* @readOnly
|
13970
|
+
*/
|
13913
13971
|
this.worldRotation = 0;
|
13914
13972
|
|
13915
13973
|
/**
|
13916
|
-
|
13917
|
-
|
13918
|
-
|
13919
|
-
|
13920
|
-
|
13921
|
-
|
13922
|
-
this.
|
13974
|
+
* The rectangular area used by filters when rendering a shader for this DisplayObject.
|
13975
|
+
*
|
13976
|
+
* @property {PIXI.Rectangle} filterArea
|
13977
|
+
* @type Rectangle
|
13978
|
+
* @default
|
13979
|
+
*/
|
13980
|
+
this.filterArea = null;
|
13923
13981
|
|
13924
13982
|
/**
|
13925
|
-
|
13926
|
-
|
13927
|
-
|
13928
|
-
|
13929
|
-
* @private
|
13930
|
-
*/
|
13931
|
-
this._cr = 1;
|
13983
|
+
* @property {number} _sr - Cached rotation value.
|
13984
|
+
* @private
|
13985
|
+
*/
|
13986
|
+
this._sr = 0;
|
13932
13987
|
|
13933
13988
|
/**
|
13934
|
-
|
13935
|
-
|
13936
|
-
|
13937
|
-
|
13938
|
-
* @type Rectangle
|
13939
|
-
*/
|
13940
|
-
this.filterArea = null;
|
13989
|
+
* @property {number} _cr - Cached rotation value.
|
13990
|
+
* @private
|
13991
|
+
*/
|
13992
|
+
this._cr = 1;
|
13941
13993
|
|
13942
13994
|
/**
|
13943
|
-
|
13944
|
-
|
13945
|
-
|
13946
|
-
* @type Rectangle
|
13947
|
-
* @private
|
13948
|
-
*/
|
13995
|
+
* @property {PIXI.Rectangle} _bounds - The cached bounds of this object.
|
13996
|
+
* @private
|
13997
|
+
*/
|
13949
13998
|
this._bounds = new PIXI.Rectangle(0, 0, 1, 1);
|
13950
13999
|
|
13951
14000
|
/**
|
13952
|
-
|
13953
|
-
|
13954
|
-
|
13955
|
-
* @type Rectangle
|
13956
|
-
* @private
|
13957
|
-
*/
|
14001
|
+
* @property {PIXI.Rectangle} _currentBounds - The most recently calculated bounds of this object.
|
14002
|
+
* @private
|
14003
|
+
*/
|
13958
14004
|
this._currentBounds = null;
|
13959
14005
|
|
13960
14006
|
/**
|
13961
|
-
|
13962
|
-
|
13963
|
-
|
13964
|
-
* @type Rectangle
|
13965
|
-
* @private
|
13966
|
-
*/
|
14007
|
+
* @property {PIXI.Rectangle} _mask - The cached mask of this object.
|
14008
|
+
* @private
|
14009
|
+
*/
|
13967
14010
|
this._mask = null;
|
13968
14011
|
|
13969
14012
|
/**
|
13970
|
-
|
13971
|
-
|
13972
|
-
|
13973
|
-
* @type Boolean
|
13974
|
-
* @private
|
13975
|
-
*/
|
14013
|
+
* @property {boolean} _cacheAsBitmap - Internal cache as bitmap flag.
|
14014
|
+
* @private
|
14015
|
+
*/
|
13976
14016
|
this._cacheAsBitmap = false;
|
13977
14017
|
|
13978
14018
|
/**
|
13979
|
-
|
13980
|
-
|
13981
|
-
|
13982
|
-
* @type Boolean
|
13983
|
-
* @private
|
13984
|
-
*/
|
14019
|
+
* @property {boolean} _cacheIsDirty - Internal dirty cache flag.
|
14020
|
+
* @private
|
14021
|
+
*/
|
13985
14022
|
this._cacheIsDirty = false;
|
13986
14023
|
|
13987
14024
|
};
|
13988
14025
|
|
13989
|
-
// constructor
|
13990
14026
|
PIXI.DisplayObject.prototype.constructor = PIXI.DisplayObject;
|
13991
14027
|
|
13992
|
-
|
13993
|
-
* Destroy this DisplayObject.
|
13994
|
-
* Removes all references to transformCallbacks, its parent, the stage, filters, bounds, mask and cached Sprites.
|
13995
|
-
*
|
13996
|
-
* @method destroy
|
13997
|
-
*/
|
13998
|
-
PIXI.DisplayObject.prototype.destroy = function()
|
13999
|
-
{
|
14000
|
-
if (this.children)
|
14001
|
-
{
|
14002
|
-
var i = this.children.length;
|
14028
|
+
PIXI.DisplayObject.prototype = {
|
14003
14029
|
|
14004
|
-
|
14030
|
+
/**
|
14031
|
+
* Destroy this DisplayObject.
|
14032
|
+
*
|
14033
|
+
* Removes any cached sprites, sets renderable flag to false, and nulls references to the Stage, filters,
|
14034
|
+
* bounds and mask.
|
14035
|
+
*
|
14036
|
+
* Also iteratively calls `destroy` on any children.
|
14037
|
+
*
|
14038
|
+
* @method PIXI.DisplayObject#destroy
|
14039
|
+
*/
|
14040
|
+
destroy: function () {
|
14041
|
+
|
14042
|
+
if (this.children)
|
14005
14043
|
{
|
14006
|
-
this.children
|
14044
|
+
var i = this.children.length;
|
14045
|
+
|
14046
|
+
while (i--)
|
14047
|
+
{
|
14048
|
+
this.children[i].destroy();
|
14049
|
+
}
|
14050
|
+
|
14051
|
+
this.children = [];
|
14007
14052
|
}
|
14008
14053
|
|
14009
|
-
this.
|
14010
|
-
|
14054
|
+
this.hitArea = null;
|
14055
|
+
this.parent = null;
|
14056
|
+
this.stage = null;
|
14057
|
+
this.worldTransform = null;
|
14058
|
+
this.filterArea = null;
|
14059
|
+
this.renderable = false;
|
14011
14060
|
|
14012
|
-
|
14013
|
-
|
14014
|
-
|
14015
|
-
this.worldTransform = null;
|
14016
|
-
this.filterArea = null;
|
14017
|
-
this._bounds = null;
|
14018
|
-
this._currentBounds = null;
|
14019
|
-
this._mask = null;
|
14061
|
+
this._bounds = null;
|
14062
|
+
this._currentBounds = null;
|
14063
|
+
this._mask = null;
|
14020
14064
|
|
14021
|
-
|
14022
|
-
this.renderable = false;
|
14065
|
+
this._destroyCachedSprite();
|
14023
14066
|
|
14024
|
-
|
14025
|
-
};
|
14067
|
+
},
|
14026
14068
|
|
14027
|
-
|
14028
|
-
|
14029
|
-
|
14030
|
-
|
14031
|
-
|
14032
|
-
|
14033
|
-
|
14069
|
+
/*
|
14070
|
+
* Updates the transform matrix this DisplayObject uses for rendering.
|
14071
|
+
*
|
14072
|
+
* If the object has no parent, and no parent parameter is provided, it will default to
|
14073
|
+
* Phaser.Game.World as the parent transform to use. If that is unavailable the transform fails to take place.
|
14074
|
+
*
|
14075
|
+
* The `parent` parameter has priority over the actual parent. Use it as a parent override.
|
14076
|
+
* Setting it does **not** change the actual parent of this DisplayObject.
|
14077
|
+
*
|
14078
|
+
* Calling this method updates the `worldTransform`, `worldAlpha`, `worldPosition`, `worldScale`
|
14079
|
+
* and `worldRotation` properties.
|
14080
|
+
*
|
14081
|
+
* If a `transformCallback` has been specified, it is called at the end of this method, and is passed
|
14082
|
+
* the new, updated, worldTransform property, along with the parent transform used.
|
14083
|
+
*
|
14084
|
+
* @method PIXI.DisplayObject#updateTransform
|
14085
|
+
* @param {PIXI.DisplayObject} [parent] - Optional parent to calculate this DisplayObjects transform from.
|
14086
|
+
* @return {PIXI.DisplayObject} - A reference to this DisplayObject.
|
14087
|
+
*/
|
14088
|
+
updateTransform: function (parent) {
|
14034
14089
|
|
14035
|
-
|
14090
|
+
if (!parent && !this.parent && !this.game)
|
14091
|
+
{
|
14092
|
+
return this;
|
14093
|
+
}
|
14036
14094
|
|
14037
|
-
var
|
14095
|
+
var p = this.parent;
|
14038
14096
|
|
14039
|
-
|
14097
|
+
if (parent)
|
14040
14098
|
{
|
14041
|
-
|
14042
|
-
|
14099
|
+
p = parent;
|
14100
|
+
}
|
14101
|
+
else if (!this.parent)
|
14102
|
+
{
|
14103
|
+
p = this.game.world;
|
14043
14104
|
}
|
14044
|
-
while(item);
|
14045
14105
|
|
14046
|
-
|
14047
|
-
|
14106
|
+
// create some matrix refs for easy access
|
14107
|
+
var pt = p.worldTransform;
|
14108
|
+
var wt = this.worldTransform;
|
14048
14109
|
|
14049
|
-
|
14110
|
+
// temporary matrix variables
|
14111
|
+
var a, b, c, d, tx, ty;
|
14050
14112
|
|
14051
|
-
|
14052
|
-
|
14053
|
-
|
14054
|
-
|
14055
|
-
|
14056
|
-
|
14057
|
-
|
14058
|
-
|
14059
|
-
|
14113
|
+
// so if rotation is between 0 then we can simplify the multiplication process..
|
14114
|
+
if (this.rotation % PIXI.PI_2)
|
14115
|
+
{
|
14116
|
+
// check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes
|
14117
|
+
if (this.rotation !== this.rotationCache)
|
14118
|
+
{
|
14119
|
+
this.rotationCache = this.rotation;
|
14120
|
+
this._sr = Math.sin(this.rotation);
|
14121
|
+
this._cr = Math.cos(this.rotation);
|
14122
|
+
}
|
14123
|
+
|
14124
|
+
// get the matrix values of the displayobject based on its transform properties..
|
14125
|
+
a = this._cr * this.scale.x;
|
14126
|
+
b = this._sr * this.scale.x;
|
14127
|
+
c = -this._sr * this.scale.y;
|
14128
|
+
d = this._cr * this.scale.y;
|
14129
|
+
tx = this.position.x;
|
14130
|
+
ty = this.position.y;
|
14131
|
+
|
14132
|
+
// check for pivot.. not often used so geared towards that fact!
|
14133
|
+
if (this.pivot.x || this.pivot.y)
|
14134
|
+
{
|
14135
|
+
tx -= this.pivot.x * a + this.pivot.y * c;
|
14136
|
+
ty -= this.pivot.x * b + this.pivot.y * d;
|
14137
|
+
}
|
14138
|
+
|
14139
|
+
// concat the parent matrix with the objects transform.
|
14140
|
+
wt.a = a * pt.a + b * pt.c;
|
14141
|
+
wt.b = a * pt.b + b * pt.d;
|
14142
|
+
wt.c = c * pt.a + d * pt.c;
|
14143
|
+
wt.d = c * pt.b + d * pt.d;
|
14144
|
+
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
14145
|
+
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
14146
|
+
}
|
14147
|
+
else
|
14148
|
+
{
|
14149
|
+
// lets do the fast version as we know there is no rotation..
|
14150
|
+
a = this.scale.x;
|
14151
|
+
d = this.scale.y;
|
14152
|
+
|
14153
|
+
tx = this.position.x - this.pivot.x * a;
|
14154
|
+
ty = this.position.y - this.pivot.y * d;
|
14155
|
+
|
14156
|
+
wt.a = a * pt.a;
|
14157
|
+
wt.b = a * pt.b;
|
14158
|
+
wt.c = d * pt.c;
|
14159
|
+
wt.d = d * pt.d;
|
14160
|
+
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
14161
|
+
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
14162
|
+
}
|
14163
|
+
|
14164
|
+
// Set the World values
|
14165
|
+
this.worldAlpha = this.alpha * p.worldAlpha;
|
14166
|
+
this.worldPosition.set(wt.tx, wt.ty);
|
14167
|
+
this.worldScale.set(this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c), this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d));
|
14168
|
+
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
14169
|
+
|
14170
|
+
// reset the bounds each time this is called!
|
14171
|
+
this._currentBounds = null;
|
14172
|
+
|
14173
|
+
// Custom callback?
|
14174
|
+
if (this.transformCallback)
|
14175
|
+
{
|
14176
|
+
this.transformCallback.call(this.transformCallbackContext, wt, pt);
|
14177
|
+
}
|
14178
|
+
|
14179
|
+
return this;
|
14060
14180
|
|
14061
|
-
get: function() {
|
14062
|
-
return this._mask;
|
14063
14181
|
},
|
14064
14182
|
|
14065
|
-
|
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;
|
14066
14193
|
|
14067
|
-
|
14194
|
+
return this;
|
14068
14195
|
|
14069
|
-
|
14196
|
+
},
|
14070
14197
|
|
14071
|
-
|
14072
|
-
|
14198
|
+
/**
|
14199
|
+
* To be overridden by classes that require it.
|
14200
|
+
*
|
14201
|
+
* @method PIXI.DisplayObject#preUpdate
|
14202
|
+
*/
|
14203
|
+
preUpdate: function () {
|
14073
14204
|
|
14074
|
-
}
|
14205
|
+
},
|
14075
14206
|
|
14076
|
-
/**
|
14077
|
-
|
14078
|
-
|
14079
|
-
|
14080
|
-
|
14081
|
-
|
14082
|
-
|
14083
|
-
|
14084
|
-
|
14085
|
-
|
14086
|
-
|
14087
|
-
|
14088
|
-
|
14207
|
+
/**
|
14208
|
+
* Generates a RenderTexture based on this DisplayObject, which can they be used to texture other Sprites.
|
14209
|
+
* This can be useful if your DisplayObject is static, or complicated, and needs to be reused multiple times.
|
14210
|
+
*
|
14211
|
+
* Please note that no garbage collection takes place on old textures. It is up to you to destroy old textures,
|
14212
|
+
* and references to them, so they don't linger in memory.
|
14213
|
+
*
|
14214
|
+
* @method PIXI.DisplayObject#generateTexture
|
14215
|
+
* @param {number} [resolution=1] - The resolution of the texture being generated.
|
14216
|
+
* @param {number} [scaleMode=PIXI.scaleModes.DEFAULT] - See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values.
|
14217
|
+
* @param {PIXI.CanvasRenderer|PIXI.WebGLRenderer} renderer - The renderer used to generate the texture.
|
14218
|
+
* @return {PIXI.RenderTexture} - A RenderTexture containing an image of this DisplayObject at the time it was invoked.
|
14219
|
+
*/
|
14220
|
+
generateTexture: function (resolution, scaleMode, renderer) {
|
14221
|
+
|
14222
|
+
var bounds = this.getLocalBounds();
|
14223
|
+
|
14224
|
+
var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer, scaleMode, resolution);
|
14225
|
+
|
14226
|
+
PIXI.DisplayObject._tempMatrix.tx = -bounds.x;
|
14227
|
+
PIXI.DisplayObject._tempMatrix.ty = -bounds.y;
|
14228
|
+
|
14229
|
+
renderTexture.render(this, PIXI.DisplayObject._tempMatrix);
|
14230
|
+
|
14231
|
+
return renderTexture;
|
14089
14232
|
|
14090
|
-
get: function() {
|
14091
|
-
return this._filters;
|
14092
14233
|
},
|
14093
14234
|
|
14094
|
-
|
14235
|
+
/**
|
14236
|
+
* If this DisplayObject has a cached Sprite, this method generates and updates it.
|
14237
|
+
*
|
14238
|
+
* @method PIXI.DisplayObject#updateCache
|
14239
|
+
* @return {PIXI.DisplayObject} - A reference to this DisplayObject.
|
14240
|
+
*/
|
14241
|
+
updateCache: function () {
|
14095
14242
|
|
14096
|
-
|
14097
|
-
{
|
14098
|
-
// now put all the passes in one place..
|
14099
|
-
var passes = [];
|
14243
|
+
this._generateCachedSprite();
|
14100
14244
|
|
14101
|
-
|
14102
|
-
{
|
14103
|
-
var filterPasses = value[i].passes;
|
14245
|
+
return this;
|
14104
14246
|
|
14105
|
-
|
14106
|
-
{
|
14107
|
-
passes.push(filterPasses[j]);
|
14108
|
-
}
|
14109
|
-
}
|
14247
|
+
},
|
14110
14248
|
|
14111
|
-
|
14112
|
-
|
14113
|
-
|
14249
|
+
/**
|
14250
|
+
* Calculates the global position of this DisplayObject, based on the position given.
|
14251
|
+
*
|
14252
|
+
* @method PIXI.DisplayObject#toGlobal
|
14253
|
+
* @param {PIXI.Point} position - The global position to calculate from.
|
14254
|
+
* @return {PIXI.Point} - A point object representing the position of this DisplayObject based on the global position given.
|
14255
|
+
*/
|
14256
|
+
toGlobal: function (position) {
|
14114
14257
|
|
14115
|
-
this.
|
14258
|
+
this.updateTransform();
|
14116
14259
|
|
14117
|
-
|
14260
|
+
return this.worldTransform.apply(position);
|
14261
|
+
|
14262
|
+
},
|
14263
|
+
|
14264
|
+
/**
|
14265
|
+
* Calculates the local position of this DisplayObject, relative to another point.
|
14266
|
+
*
|
14267
|
+
* @method PIXI.DisplayObject#toLocal
|
14268
|
+
* @param {PIXI.Point} position - The world origin to calculate from.
|
14269
|
+
* @param {PIXI.DisplayObject} [from] - An optional DisplayObject to calculate the global position from.
|
14270
|
+
* @return {PIXI.Point} - A point object representing the position of this DisplayObject based on the global position given.
|
14271
|
+
*/
|
14272
|
+
toLocal: function (position, from) {
|
14273
|
+
|
14274
|
+
if (from)
|
14118
14275
|
{
|
14119
|
-
|
14276
|
+
position = from.toGlobal(position);
|
14120
14277
|
}
|
14121
|
-
}
|
14122
|
-
});
|
14123
14278
|
|
14124
|
-
|
14125
|
-
|
14126
|
-
|
14127
|
-
* To remove simply set this property to 'null'
|
14128
|
-
* @property cacheAsBitmap
|
14129
|
-
* @type Boolean
|
14130
|
-
*/
|
14131
|
-
Object.defineProperty(PIXI.DisplayObject.prototype, 'cacheAsBitmap', {
|
14279
|
+
this.updateTransform();
|
14280
|
+
|
14281
|
+
return this.worldTransform.applyInverse(position);
|
14132
14282
|
|
14133
|
-
get: function() {
|
14134
|
-
return this._cacheAsBitmap;
|
14135
14283
|
},
|
14136
14284
|
|
14137
|
-
|
14285
|
+
/**
|
14286
|
+
* Internal method.
|
14287
|
+
*
|
14288
|
+
* @method PIXI.DisplayObject#_renderCachedSprite
|
14289
|
+
* @private
|
14290
|
+
* @param {Object} renderSession - The render session
|
14291
|
+
*/
|
14292
|
+
_renderCachedSprite: function (renderSession) {
|
14138
14293
|
|
14139
|
-
|
14140
|
-
{
|
14141
|
-
return;
|
14142
|
-
}
|
14294
|
+
this._cachedSprite.worldAlpha = this.worldAlpha;
|
14143
14295
|
|
14144
|
-
if (
|
14296
|
+
if (renderSession.gl)
|
14145
14297
|
{
|
14146
|
-
this.
|
14298
|
+
PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);
|
14147
14299
|
}
|
14148
14300
|
else
|
14149
14301
|
{
|
14150
|
-
this.
|
14302
|
+
PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite, renderSession);
|
14151
14303
|
}
|
14152
14304
|
|
14153
|
-
|
14154
|
-
}
|
14155
|
-
|
14156
|
-
});
|
14305
|
+
},
|
14157
14306
|
|
14158
|
-
|
14159
|
-
|
14160
|
-
|
14161
|
-
|
14162
|
-
|
14163
|
-
|
14164
|
-
|
14165
|
-
* Setting it does **not** change the actual parent of this DisplayObject, it just uses the parent for the transform update.
|
14166
|
-
*
|
14167
|
-
* @method updateTransform
|
14168
|
-
* @param {DisplayObject} [parent] - Optional parent to parent this DisplayObject transform from.
|
14169
|
-
*/
|
14170
|
-
PIXI.DisplayObject.prototype.updateTransform = function(parent)
|
14171
|
-
{
|
14172
|
-
if (!parent && !this.parent && !this.game)
|
14173
|
-
{
|
14174
|
-
return;
|
14175
|
-
}
|
14307
|
+
/**
|
14308
|
+
* Internal method.
|
14309
|
+
*
|
14310
|
+
* @method PIXI.DisplayObject#_generateCachedSprite
|
14311
|
+
* @private
|
14312
|
+
*/
|
14313
|
+
_generateCachedSprite: function () {
|
14176
14314
|
|
14177
|
-
|
14315
|
+
this._cacheAsBitmap = false;
|
14178
14316
|
|
14179
|
-
|
14180
|
-
{
|
14181
|
-
p = parent;
|
14182
|
-
}
|
14183
|
-
else if (!this.parent)
|
14184
|
-
{
|
14185
|
-
p = this.game.world;
|
14186
|
-
}
|
14317
|
+
var bounds = this.getLocalBounds();
|
14187
14318
|
|
14188
|
-
|
14189
|
-
|
14190
|
-
|
14319
|
+
// Round it off and force non-zero dimensions
|
14320
|
+
bounds.width = Math.max(1, Math.ceil(bounds.width));
|
14321
|
+
bounds.height = Math.max(1, Math.ceil(bounds.height));
|
14191
14322
|
|
14192
|
-
|
14193
|
-
var a, b, c, d, tx, ty;
|
14323
|
+
this.updateTransform();
|
14194
14324
|
|
14195
|
-
|
14196
|
-
if (this.rotation % PIXI.PI_2)
|
14197
|
-
{
|
14198
|
-
// check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes
|
14199
|
-
if (this.rotation !== this.rotationCache)
|
14325
|
+
if (!this._cachedSprite)
|
14200
14326
|
{
|
14201
|
-
|
14202
|
-
this.
|
14203
|
-
this.
|
14327
|
+
var renderTexture = new PIXI.RenderTexture(bounds.width, bounds.height);
|
14328
|
+
this._cachedSprite = new PIXI.Sprite(renderTexture);
|
14329
|
+
this._cachedSprite.worldTransform = this.worldTransform;
|
14204
14330
|
}
|
14205
|
-
|
14206
|
-
// get the matrix values of the displayobject based on its transform properties..
|
14207
|
-
a = this._cr * this.scale.x;
|
14208
|
-
b = this._sr * this.scale.x;
|
14209
|
-
c = -this._sr * this.scale.y;
|
14210
|
-
d = this._cr * this.scale.y;
|
14211
|
-
tx = this.position.x;
|
14212
|
-
ty = this.position.y;
|
14213
|
-
|
14214
|
-
// check for pivot.. not often used so geared towards that fact!
|
14215
|
-
if (this.pivot.x || this.pivot.y)
|
14331
|
+
else
|
14216
14332
|
{
|
14217
|
-
|
14218
|
-
ty -= this.pivot.x * b + this.pivot.y * d;
|
14333
|
+
this._cachedSprite.texture.resize(bounds.width, bounds.height);
|
14219
14334
|
}
|
14220
14335
|
|
14221
|
-
//
|
14222
|
-
|
14223
|
-
wt.b = a * pt.b + b * pt.d;
|
14224
|
-
wt.c = c * pt.a + d * pt.c;
|
14225
|
-
wt.d = c * pt.b + d * pt.d;
|
14226
|
-
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
14227
|
-
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
14228
|
-
}
|
14229
|
-
else
|
14230
|
-
{
|
14231
|
-
// lets do the fast version as we know there is no rotation..
|
14232
|
-
a = this.scale.x;
|
14233
|
-
d = this.scale.y;
|
14336
|
+
// Remove filters
|
14337
|
+
var tempFilters = this._filters;
|
14234
14338
|
|
14235
|
-
|
14236
|
-
|
14339
|
+
this._filters = null;
|
14340
|
+
this._cachedSprite.filters = tempFilters;
|
14237
14341
|
|
14238
|
-
|
14239
|
-
|
14240
|
-
wt.c = d * pt.c;
|
14241
|
-
wt.d = d * pt.d;
|
14242
|
-
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
14243
|
-
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
14244
|
-
}
|
14342
|
+
PIXI.DisplayObject._tempMatrix.tx = -bounds.x;
|
14343
|
+
PIXI.DisplayObject._tempMatrix.ty = -bounds.y;
|
14245
14344
|
|
14246
|
-
|
14247
|
-
|
14248
|
-
|
14249
|
-
this.worldScale.set(this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c), this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d));
|
14250
|
-
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
14345
|
+
this._cachedSprite.texture.render(this, PIXI.DisplayObject._tempMatrix, true);
|
14346
|
+
this._cachedSprite.anchor.x = -(bounds.x / bounds.width);
|
14347
|
+
this._cachedSprite.anchor.y = -(bounds.y / bounds.height);
|
14251
14348
|
|
14252
|
-
|
14253
|
-
|
14349
|
+
this._filters = tempFilters;
|
14350
|
+
|
14351
|
+
this._cacheAsBitmap = true;
|
14352
|
+
|
14353
|
+
},
|
14354
|
+
|
14355
|
+
/**
|
14356
|
+
* Destroys a cached Sprite.
|
14357
|
+
*
|
14358
|
+
* @method PIXI.DisplayObject#_destroyCachedSprite
|
14359
|
+
* @private
|
14360
|
+
*/
|
14361
|
+
_destroyCachedSprite: function () {
|
14362
|
+
|
14363
|
+
if (!this._cachedSprite)
|
14364
|
+
{
|
14365
|
+
return;
|
14366
|
+
}
|
14367
|
+
|
14368
|
+
this._cachedSprite.texture.destroy(true);
|
14369
|
+
|
14370
|
+
this._cachedSprite = null;
|
14254
14371
|
|
14255
|
-
// Custom callback?
|
14256
|
-
if (this.transformCallback)
|
14257
|
-
{
|
14258
|
-
this.transformCallback.call(this.transformCallbackContext, wt, pt);
|
14259
14372
|
}
|
14260
14373
|
|
14261
14374
|
};
|
14262
14375
|
|
14263
|
-
//
|
14376
|
+
// Alias for updateTransform. As used in DisplayObject container, etc.
|
14264
14377
|
PIXI.DisplayObject.prototype.displayObjectUpdateTransform = PIXI.DisplayObject.prototype.updateTransform;
|
14265
14378
|
|
14266
|
-
|
14267
|
-
* Retrieves the bounds of the displayObject as a rectangle object
|
14268
|
-
*
|
14269
|
-
* @method getBounds
|
14270
|
-
* @param matrix {Matrix}
|
14271
|
-
* @return {Rectangle} the rectangular bounding area
|
14272
|
-
*/
|
14273
|
-
PIXI.DisplayObject.prototype.getBounds = function(matrix)
|
14274
|
-
{
|
14275
|
-
matrix = matrix;//just to get passed js hinting (and preserve inheritance)
|
14276
|
-
return PIXI.EmptyRectangle;
|
14277
|
-
};
|
14379
|
+
Object.defineProperties(PIXI.DisplayObject.prototype, {
|
14278
14380
|
|
14279
|
-
/**
|
14280
|
-
|
14281
|
-
|
14282
|
-
|
14283
|
-
|
14284
|
-
|
14285
|
-
|
14286
|
-
{
|
14287
|
-
return this.getBounds(PIXI.identityMatrix);///PIXI.EmptyRectangle();
|
14288
|
-
};
|
14381
|
+
/**
|
14382
|
+
* The horizontal position of the DisplayObject, in pixels, relative to its parent.
|
14383
|
+
* If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead.
|
14384
|
+
* @name PIXI.DisplayObject#x
|
14385
|
+
* @property {number} x - The horizontal position of the DisplayObject, in pixels, relative to its parent.
|
14386
|
+
*/
|
14387
|
+
'x': {
|
14289
14388
|
|
14290
|
-
|
14291
|
-
* Sets the object's stage reference, the stage this object is connected to
|
14292
|
-
*
|
14293
|
-
* @method setStageReference
|
14294
|
-
* @param stage {Stage} the stage that the object will have as its current stage reference
|
14295
|
-
*/
|
14296
|
-
PIXI.DisplayObject.prototype.setStageReference = function(stage)
|
14297
|
-
{
|
14298
|
-
this.stage = stage;
|
14299
|
-
};
|
14389
|
+
get: function () {
|
14300
14390
|
|
14301
|
-
|
14302
|
-
* Empty, to be overridden by classes that require it.
|
14303
|
-
*
|
14304
|
-
* @method preUpdate
|
14305
|
-
*/
|
14306
|
-
PIXI.DisplayObject.prototype.preUpdate = function()
|
14307
|
-
{
|
14308
|
-
};
|
14391
|
+
return this.position.x;
|
14309
14392
|
|
14310
|
-
|
14311
|
-
* Useful function that returns a texture of the displayObject object that can then be used to create sprites
|
14312
|
-
* This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times.
|
14313
|
-
*
|
14314
|
-
* @method generateTexture
|
14315
|
-
* @param resolution {Number} The resolution of the texture being generated
|
14316
|
-
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
|
14317
|
-
* @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture.
|
14318
|
-
* @return {RenderTexture} a texture of the graphics object
|
14319
|
-
*/
|
14320
|
-
PIXI.DisplayObject.prototype.generateTexture = function(resolution, scaleMode, renderer)
|
14321
|
-
{
|
14322
|
-
var bounds = this.getLocalBounds();
|
14393
|
+
},
|
14323
14394
|
|
14324
|
-
|
14325
|
-
|
14326
|
-
PIXI.DisplayObject._tempMatrix.tx = -bounds.x;
|
14327
|
-
PIXI.DisplayObject._tempMatrix.ty = -bounds.y;
|
14328
|
-
|
14329
|
-
renderTexture.render(this, PIXI.DisplayObject._tempMatrix);
|
14395
|
+
set: function (value) {
|
14330
14396
|
|
14331
|
-
|
14332
|
-
};
|
14397
|
+
this.position.x = value;
|
14333
14398
|
|
14334
|
-
|
14335
|
-
* Generates and updates the cached sprite for this object.
|
14336
|
-
*
|
14337
|
-
* @method updateCache
|
14338
|
-
*/
|
14339
|
-
PIXI.DisplayObject.prototype.updateCache = function()
|
14340
|
-
{
|
14341
|
-
this._generateCachedSprite();
|
14342
|
-
};
|
14399
|
+
}
|
14343
14400
|
|
14344
|
-
|
14345
|
-
* Calculates the global position of the display object
|
14346
|
-
*
|
14347
|
-
* @method toGlobal
|
14348
|
-
* @param position {Point} The world origin to calculate from
|
14349
|
-
* @return {Point} A point object representing the position of this object
|
14350
|
-
*/
|
14351
|
-
PIXI.DisplayObject.prototype.toGlobal = function(position)
|
14352
|
-
{
|
14353
|
-
// don't need to u[date the lot
|
14354
|
-
this.displayObjectUpdateTransform();
|
14355
|
-
return this.worldTransform.apply(position);
|
14356
|
-
};
|
14401
|
+
},
|
14357
14402
|
|
14358
|
-
/**
|
14359
|
-
|
14360
|
-
|
14361
|
-
|
14362
|
-
|
14363
|
-
|
14364
|
-
|
14365
|
-
*/
|
14366
|
-
PIXI.DisplayObject.prototype.toLocal = function(position, from)
|
14367
|
-
{
|
14368
|
-
if (from)
|
14369
|
-
{
|
14370
|
-
position = from.toGlobal(position);
|
14371
|
-
}
|
14403
|
+
/**
|
14404
|
+
* The vertical position of the DisplayObject, in pixels, relative to its parent.
|
14405
|
+
* If you need the world position of the DisplayObject, use `DisplayObject.worldPosition` instead.
|
14406
|
+
* @name PIXI.DisplayObject#y
|
14407
|
+
* @property {number} y - The vertical position of the DisplayObject, in pixels, relative to its parent.
|
14408
|
+
*/
|
14409
|
+
'y': {
|
14372
14410
|
|
14373
|
-
|
14374
|
-
this.displayObjectUpdateTransform();
|
14411
|
+
get: function () {
|
14375
14412
|
|
14376
|
-
|
14377
|
-
};
|
14413
|
+
return this.position.y;
|
14378
14414
|
|
14379
|
-
|
14380
|
-
* Internal method.
|
14381
|
-
*
|
14382
|
-
* @method _renderCachedSprite
|
14383
|
-
* @param renderSession {Object} The render session
|
14384
|
-
* @private
|
14385
|
-
*/
|
14386
|
-
PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession)
|
14387
|
-
{
|
14388
|
-
this._cachedSprite.worldAlpha = this.worldAlpha;
|
14415
|
+
},
|
14389
14416
|
|
14390
|
-
|
14391
|
-
{
|
14392
|
-
PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);
|
14393
|
-
}
|
14394
|
-
else
|
14395
|
-
{
|
14396
|
-
PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite, renderSession);
|
14397
|
-
}
|
14398
|
-
};
|
14417
|
+
set: function (value) {
|
14399
14418
|
|
14400
|
-
|
14401
|
-
* Internal method.
|
14402
|
-
*
|
14403
|
-
* @method _generateCachedSprite
|
14404
|
-
* @private
|
14405
|
-
*/
|
14406
|
-
PIXI.DisplayObject.prototype._generateCachedSprite = function()
|
14407
|
-
{
|
14408
|
-
this._cacheAsBitmap = false;
|
14419
|
+
this.position.y = value;
|
14409
14420
|
|
14410
|
-
|
14421
|
+
}
|
14411
14422
|
|
14412
|
-
|
14413
|
-
bounds.width = Math.max(1, Math.ceil(bounds.width));
|
14414
|
-
bounds.height = Math.max(1, Math.ceil(bounds.height));
|
14423
|
+
},
|
14415
14424
|
|
14416
|
-
|
14425
|
+
/**
|
14426
|
+
* Indicates if this DisplayObject is visible, based on it, and all of its parents, `visible` property values.
|
14427
|
+
* @name PIXI.DisplayObject#worldVisible
|
14428
|
+
* @property {boolean} worldVisible - Indicates if this DisplayObject is visible, based on it, and all of its parents, `visible` property values.
|
14429
|
+
*/
|
14430
|
+
'worldVisible': {
|
14417
14431
|
|
14418
|
-
|
14419
|
-
{
|
14420
|
-
var renderTexture = new PIXI.RenderTexture(bounds.width, bounds.height);
|
14421
|
-
this._cachedSprite = new PIXI.Sprite(renderTexture);
|
14422
|
-
this._cachedSprite.worldTransform = this.worldTransform;
|
14423
|
-
}
|
14424
|
-
else
|
14425
|
-
{
|
14426
|
-
this._cachedSprite.texture.resize(bounds.width, bounds.height);
|
14427
|
-
}
|
14432
|
+
get: function () {
|
14428
14433
|
|
14429
|
-
|
14430
|
-
|
14431
|
-
|
14432
|
-
|
14434
|
+
if (!this.visible)
|
14435
|
+
{
|
14436
|
+
return false;
|
14437
|
+
}
|
14438
|
+
else
|
14439
|
+
{
|
14440
|
+
var item = this.parent;
|
14433
14441
|
|
14434
|
-
|
14435
|
-
|
14436
|
-
|
14442
|
+
do
|
14443
|
+
{
|
14444
|
+
if (!item.visible)
|
14445
|
+
{
|
14446
|
+
return false;
|
14447
|
+
}
|
14437
14448
|
|
14438
|
-
|
14439
|
-
|
14440
|
-
|
14449
|
+
item = item.parent;
|
14450
|
+
}
|
14451
|
+
while (item);
|
14441
14452
|
|
14442
|
-
|
14453
|
+
return true;
|
14454
|
+
}
|
14443
14455
|
|
14444
|
-
|
14445
|
-
};
|
14456
|
+
}
|
14446
14457
|
|
14447
|
-
|
14448
|
-
* Destroys the cached sprite.
|
14449
|
-
*
|
14450
|
-
* @method _destroyCachedSprite
|
14451
|
-
* @private
|
14452
|
-
*/
|
14453
|
-
PIXI.DisplayObject.prototype._destroyCachedSprite = function()
|
14454
|
-
{
|
14455
|
-
if (!this._cachedSprite) return;
|
14458
|
+
},
|
14456
14459
|
|
14457
|
-
|
14460
|
+
/**
|
14461
|
+
* Sets a mask for this DisplayObject. A mask is an instance of a Graphics object.
|
14462
|
+
* When applied it limits the visible area of this DisplayObject to the shape of the mask.
|
14463
|
+
* Under a Canvas renderer it uses shape clipping. Under a WebGL renderer it uses a Stencil Buffer.
|
14464
|
+
* To remove a mask, set this property to `null`.
|
14465
|
+
*
|
14466
|
+
* @name PIXI.DisplayObject#mask
|
14467
|
+
* @property {PIXI.Graphics} mask - The mask applied to this DisplayObject. Set to `null` to remove an existing mask.
|
14468
|
+
*/
|
14469
|
+
'mask': {
|
14458
14470
|
|
14459
|
-
|
14460
|
-
this._cachedSprite = null;
|
14461
|
-
};
|
14471
|
+
get: function () {
|
14462
14472
|
|
14463
|
-
|
14464
|
-
* Renders the object using the WebGL renderer
|
14465
|
-
*
|
14466
|
-
* @method _renderWebGL
|
14467
|
-
* @param renderSession {RenderSession}
|
14468
|
-
* @private
|
14469
|
-
*/
|
14470
|
-
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
|
14471
|
-
{
|
14472
|
-
// OVERWRITE;
|
14473
|
-
// this line is just here to pass jshinting :)
|
14474
|
-
renderSession = renderSession;
|
14475
|
-
};
|
14473
|
+
return this._mask;
|
14476
14474
|
|
14477
|
-
|
14478
|
-
* Renders the object using the Canvas renderer
|
14479
|
-
*
|
14480
|
-
* @method _renderCanvas
|
14481
|
-
* @param renderSession {RenderSession}
|
14482
|
-
* @private
|
14483
|
-
*/
|
14484
|
-
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
|
14485
|
-
{
|
14486
|
-
// OVERWRITE;
|
14487
|
-
// this line is just here to pass jshinting :)
|
14488
|
-
renderSession = renderSession;
|
14489
|
-
};
|
14475
|
+
},
|
14490
14476
|
|
14491
|
-
|
14492
|
-
|
14493
|
-
|
14494
|
-
|
14495
|
-
|
14496
|
-
|
14497
|
-
|
14477
|
+
set: function (value) {
|
14478
|
+
|
14479
|
+
if (this._mask)
|
14480
|
+
{
|
14481
|
+
this._mask.isMask = false;
|
14482
|
+
}
|
14483
|
+
|
14484
|
+
this._mask = value;
|
14485
|
+
|
14486
|
+
if (value)
|
14487
|
+
{
|
14488
|
+
this._mask.isMask = true;
|
14489
|
+
}
|
14490
|
+
|
14491
|
+
}
|
14498
14492
|
|
14499
|
-
get: function() {
|
14500
|
-
return this.position.x;
|
14501
14493
|
},
|
14502
14494
|
|
14503
|
-
|
14504
|
-
|
14505
|
-
|
14495
|
+
/**
|
14496
|
+
* Sets the filters for this DisplayObject. This is a WebGL only feature, and is ignored by the Canvas
|
14497
|
+
* Renderer. A filter is a shader applied to this DisplayObject. You can modify the placement of the filter
|
14498
|
+
* using `DisplayObject.filterArea`.
|
14499
|
+
*
|
14500
|
+
* To remove filters, set this property to `null`.
|
14501
|
+
*
|
14502
|
+
* Note: You cannot have a filter set, and a MULTIPLY Blend Mode active, at the same time. Setting a
|
14503
|
+
* filter will reset this DisplayObjects blend mode to NORMAL.
|
14504
|
+
*
|
14505
|
+
* @name PIXI.DisplayObject#filters
|
14506
|
+
* @property {Array} filters - An Array of PIXI.AbstractFilter objects, or objects that extend them.
|
14507
|
+
*/
|
14508
|
+
'filters': {
|
14506
14509
|
|
14507
|
-
|
14510
|
+
get: function () {
|
14508
14511
|
|
14509
|
-
|
14510
|
-
|
14511
|
-
|
14512
|
-
|
14513
|
-
|
14514
|
-
|
14515
|
-
|
14512
|
+
return this._filters;
|
14513
|
+
|
14514
|
+
},
|
14515
|
+
|
14516
|
+
set: function (value) {
|
14517
|
+
|
14518
|
+
if (Array.isArray(value))
|
14519
|
+
{
|
14520
|
+
// Put all the passes in one place.
|
14521
|
+
var passes = [];
|
14522
|
+
|
14523
|
+
for (var i = 0; i < value.length; i++)
|
14524
|
+
{
|
14525
|
+
var filterPasses = value[i].passes;
|
14526
|
+
|
14527
|
+
for (var j = 0; j < filterPasses.length; j++)
|
14528
|
+
{
|
14529
|
+
passes.push(filterPasses[j]);
|
14530
|
+
}
|
14531
|
+
}
|
14532
|
+
|
14533
|
+
// Needed any more?
|
14534
|
+
this._filterBlock = { target: this, filterPasses: passes };
|
14535
|
+
}
|
14536
|
+
|
14537
|
+
this._filters = value;
|
14538
|
+
|
14539
|
+
if (this.blendMode && this.blendMode === PIXI.blendModes.MULTIPLY)
|
14540
|
+
{
|
14541
|
+
this.blendMode = PIXI.blendModes.NORMAL;
|
14542
|
+
}
|
14543
|
+
|
14544
|
+
}
|
14516
14545
|
|
14517
|
-
get: function() {
|
14518
|
-
return this.position.y;
|
14519
14546
|
},
|
14520
14547
|
|
14521
|
-
|
14522
|
-
|
14548
|
+
/**
|
14549
|
+
* Sets if this DisplayObject should be cached as a bitmap.
|
14550
|
+
*
|
14551
|
+
* When invoked it will take a snapshot of the DisplayObject, as it is at that moment, and store it
|
14552
|
+
* in a RenderTexture. This is then used whenever this DisplayObject is rendered. It can provide a
|
14553
|
+
* performance benefit for complex, but static, DisplayObjects. I.e. those with lots of children.
|
14554
|
+
*
|
14555
|
+
* Cached Bitmaps do not track their parents. If you update a property of this DisplayObject, it will not
|
14556
|
+
* re-generate the cached bitmap automatically. To do that you need to call `DisplayObject.updateCache`.
|
14557
|
+
*
|
14558
|
+
* To remove a cached bitmap, set this property to `null`.
|
14559
|
+
*
|
14560
|
+
* @name PIXI.DisplayObject#cacheAsBitmap
|
14561
|
+
* @property {boolean} cacheAsBitmap - Cache this DisplayObject as a Bitmap. Set to `null` to remove an existing cached bitmap.
|
14562
|
+
*/
|
14563
|
+
'cacheAsBitmap': {
|
14564
|
+
|
14565
|
+
get: function () {
|
14566
|
+
|
14567
|
+
return this._cacheAsBitmap;
|
14568
|
+
|
14569
|
+
},
|
14570
|
+
|
14571
|
+
set: function (value) {
|
14572
|
+
|
14573
|
+
if (this._cacheAsBitmap === value)
|
14574
|
+
{
|
14575
|
+
return;
|
14576
|
+
}
|
14577
|
+
|
14578
|
+
if (value)
|
14579
|
+
{
|
14580
|
+
this._generateCachedSprite();
|
14581
|
+
}
|
14582
|
+
else
|
14583
|
+
{
|
14584
|
+
this._destroyCachedSprite();
|
14585
|
+
}
|
14586
|
+
|
14587
|
+
this._cacheAsBitmap = value;
|
14588
|
+
|
14589
|
+
}
|
14590
|
+
|
14523
14591
|
}
|
14524
14592
|
|
14525
14593
|
});
|
@@ -14854,6 +14922,8 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
|
|
14854
14922
|
return PIXI.EmptyRectangle;
|
14855
14923
|
}
|
14856
14924
|
|
14925
|
+
this.updateTransform();
|
14926
|
+
|
14857
14927
|
var minX = Infinity;
|
14858
14928
|
var minY = Infinity;
|
14859
14929
|
|
@@ -15550,44 +15620,6 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
|
|
15550
15620
|
|
15551
15621
|
};
|
15552
15622
|
|
15553
|
-
// some helper functions..
|
15554
|
-
|
15555
|
-
/**
|
15556
|
-
*
|
15557
|
-
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
|
15558
|
-
* The frame ids are created when a Texture packer file has been loaded
|
15559
|
-
*
|
15560
|
-
* @method fromFrame
|
15561
|
-
* @static
|
15562
|
-
* @param frameId {String} The frame Id of the texture in the cache
|
15563
|
-
* @return {Sprite} A new Sprite using a texture from the texture cache matching the frameId
|
15564
|
-
*/
|
15565
|
-
PIXI.Sprite.fromFrame = function(frameId)
|
15566
|
-
{
|
15567
|
-
var texture = PIXI.TextureCache[frameId];
|
15568
|
-
|
15569
|
-
if (!texture) throw new Error('The frameId "' + frameId + '" does not exist in the texture cache' + this);
|
15570
|
-
|
15571
|
-
return new PIXI.Sprite(texture);
|
15572
|
-
};
|
15573
|
-
|
15574
|
-
/**
|
15575
|
-
*
|
15576
|
-
* Helper function that creates a sprite that will contain a texture based on an image url
|
15577
|
-
* If the image is not in the texture cache it will be loaded
|
15578
|
-
*
|
15579
|
-
* @method fromImage
|
15580
|
-
* @static
|
15581
|
-
* @param imageId {String} The image url of the texture
|
15582
|
-
* @return {Sprite} A new Sprite using a texture from the texture cache matching the image id
|
15583
|
-
*/
|
15584
|
-
PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
|
15585
|
-
{
|
15586
|
-
var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
|
15587
|
-
|
15588
|
-
return new PIXI.Sprite(texture);
|
15589
|
-
};
|
15590
|
-
|
15591
15623
|
/**
|
15592
15624
|
* @author Mat Groves http://matgroves.com/
|
15593
15625
|
*/
|
@@ -15934,7 +15966,7 @@ PIXI.CanvasPool = {
|
|
15934
15966
|
|
15935
15967
|
for (var i = 0; i < pool.length; i++)
|
15936
15968
|
{
|
15937
|
-
if (pool[i].parent
|
15969
|
+
if (!pool[i].parent)
|
15938
15970
|
{
|
15939
15971
|
return i;
|
15940
15972
|
}
|
@@ -15960,6 +15992,8 @@ PIXI.CanvasPool = {
|
|
15960
15992
|
if (pool[i].parent === parent)
|
15961
15993
|
{
|
15962
15994
|
pool[i].parent = null;
|
15995
|
+
pool[i].canvas.width = 1;
|
15996
|
+
pool[i].canvas.height = 1;
|
15963
15997
|
}
|
15964
15998
|
}
|
15965
15999
|
|
@@ -15981,6 +16015,8 @@ PIXI.CanvasPool = {
|
|
15981
16015
|
if (pool[i].canvas === canvas)
|
15982
16016
|
{
|
15983
16017
|
pool[i].parent = null;
|
16018
|
+
pool[i].canvas.width = 1;
|
16019
|
+
pool[i].canvas.height = 1;
|
15984
16020
|
}
|
15985
16021
|
}
|
15986
16022
|
|
@@ -16000,7 +16036,7 @@ PIXI.CanvasPool = {
|
|
16000
16036
|
|
16001
16037
|
for (var i = 0; i < pool.length; i++)
|
16002
16038
|
{
|
16003
|
-
if (pool[i].parent
|
16039
|
+
if (pool[i].parent)
|
16004
16040
|
{
|
16005
16041
|
c++;
|
16006
16042
|
}
|
@@ -16024,7 +16060,7 @@ PIXI.CanvasPool = {
|
|
16024
16060
|
|
16025
16061
|
for (var i = 0; i < pool.length; i++)
|
16026
16062
|
{
|
16027
|
-
if (pool[i].parent
|
16063
|
+
if (!pool[i].parent)
|
16028
16064
|
{
|
16029
16065
|
c++;
|
16030
16066
|
}
|
@@ -20428,17 +20464,13 @@ PIXI.CanvasRenderer.prototype.mapBlendModes = function () {
|
|
20428
20464
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
20429
20465
|
*/
|
20430
20466
|
|
20431
|
-
PIXI.BaseTextureCache = {};
|
20432
|
-
|
20433
|
-
PIXI.BaseTextureCacheIdGenerator = 0;
|
20434
|
-
|
20435
20467
|
/**
|
20436
20468
|
* A texture stores the information that represents an image. All textures have a base texture.
|
20437
20469
|
*
|
20438
20470
|
* @class BaseTexture
|
20439
20471
|
* @uses EventTarget
|
20440
20472
|
* @constructor
|
20441
|
-
* @param source {String} the source object (image or canvas)
|
20473
|
+
* @param source {String|Canvas} the source object (image or canvas)
|
20442
20474
|
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
|
20443
20475
|
*/
|
20444
20476
|
PIXI.BaseTexture = function(source, scaleMode)
|
@@ -20495,8 +20527,6 @@ PIXI.BaseTexture = function(source, scaleMode)
|
|
20495
20527
|
*/
|
20496
20528
|
this.source = source;
|
20497
20529
|
|
20498
|
-
this._UID = PIXI._UID++;
|
20499
|
-
|
20500
20530
|
/**
|
20501
20531
|
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
|
20502
20532
|
*
|
@@ -20555,12 +20585,6 @@ PIXI.BaseTexture = function(source, scaleMode)
|
|
20555
20585
|
*/
|
20556
20586
|
this.skipRender = false;
|
20557
20587
|
|
20558
|
-
/**
|
20559
|
-
* @property imageUrl
|
20560
|
-
* @type String
|
20561
|
-
*/
|
20562
|
-
this.imageUrl = null;
|
20563
|
-
|
20564
20588
|
/**
|
20565
20589
|
* @property _powerOf2
|
20566
20590
|
* @type Boolean
|
@@ -20587,7 +20611,6 @@ PIXI.BaseTexture.prototype.forceLoaded = function(width, height)
|
|
20587
20611
|
this.width = width;
|
20588
20612
|
this.height = height;
|
20589
20613
|
this.dirty();
|
20590
|
-
|
20591
20614
|
};
|
20592
20615
|
|
20593
20616
|
/**
|
@@ -20597,23 +20620,9 @@ PIXI.BaseTexture.prototype.forceLoaded = function(width, height)
|
|
20597
20620
|
*/
|
20598
20621
|
PIXI.BaseTexture.prototype.destroy = function()
|
20599
20622
|
{
|
20600
|
-
if (this.
|
20601
|
-
{
|
20602
|
-
delete PIXI.BaseTextureCache[this.imageUrl];
|
20603
|
-
delete PIXI.TextureCache[this.imageUrl];
|
20604
|
-
|
20605
|
-
this.imageUrl = null;
|
20606
|
-
|
20607
|
-
if (!navigator.isCocoonJS) this.source.src = '';
|
20608
|
-
}
|
20609
|
-
else if (this.source)
|
20623
|
+
if (this.source)
|
20610
20624
|
{
|
20611
20625
|
PIXI.CanvasPool.removeByCanvas(this.source);
|
20612
|
-
|
20613
|
-
if (this.source._pixiId)
|
20614
|
-
{
|
20615
|
-
delete PIXI.BaseTextureCache[this.source._pixiId];
|
20616
|
-
}
|
20617
20626
|
}
|
20618
20627
|
|
20619
20628
|
this.source = null;
|
@@ -20626,12 +20635,11 @@ PIXI.BaseTexture.prototype.destroy = function()
|
|
20626
20635
|
*
|
20627
20636
|
* @method updateSourceImage
|
20628
20637
|
* @param newSrc {String} the path of the image
|
20638
|
+
* @deprecated This method is deprecated. Please use Phaser.Sprite.loadTexture instead.
|
20629
20639
|
*/
|
20630
20640
|
PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
|
20631
20641
|
{
|
20632
|
-
|
20633
|
-
this.source.src = null;
|
20634
|
-
this.source.src = newSrc;
|
20642
|
+
console.warn("PIXI.BaseTexture.updateSourceImage is deprecated. Use Phaser.Sprite.loadTexture instead.");
|
20635
20643
|
};
|
20636
20644
|
|
20637
20645
|
/**
|
@@ -20675,49 +20683,6 @@ PIXI.BaseTexture.prototype.unloadFromGPU = function()
|
|
20675
20683
|
this.dirty();
|
20676
20684
|
};
|
20677
20685
|
|
20678
|
-
/**
|
20679
|
-
* Helper function that creates a base texture from the given image url.
|
20680
|
-
* If the image is not in the base texture cache it will be created and loaded.
|
20681
|
-
*
|
20682
|
-
* @static
|
20683
|
-
* @method fromImage
|
20684
|
-
* @param imageUrl {String} The image url of the texture
|
20685
|
-
* @param crossorigin {Boolean}
|
20686
|
-
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
|
20687
|
-
* @return {BaseTexture}
|
20688
|
-
*/
|
20689
|
-
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
20690
|
-
{
|
20691
|
-
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
20692
|
-
|
20693
|
-
if(crossorigin === undefined && imageUrl.indexOf('data:') === -1) crossorigin = true;
|
20694
|
-
|
20695
|
-
if(!baseTexture)
|
20696
|
-
{
|
20697
|
-
// new Image() breaks tex loading in some versions of Chrome.
|
20698
|
-
// See https://code.google.com/p/chromium/issues/detail?id=238071
|
20699
|
-
var image = new Image();
|
20700
|
-
|
20701
|
-
if (crossorigin)
|
20702
|
-
{
|
20703
|
-
image.crossOrigin = '';
|
20704
|
-
}
|
20705
|
-
|
20706
|
-
image.src = imageUrl;
|
20707
|
-
baseTexture = new PIXI.BaseTexture(image, scaleMode);
|
20708
|
-
baseTexture.imageUrl = imageUrl;
|
20709
|
-
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
20710
|
-
|
20711
|
-
// if there is an @2x at the end of the url we are going to assume its a highres image
|
20712
|
-
if( imageUrl.indexOf(PIXI.RETINA_PREFIX + '.') !== -1)
|
20713
|
-
{
|
20714
|
-
baseTexture.resolution = 2;
|
20715
|
-
}
|
20716
|
-
}
|
20717
|
-
|
20718
|
-
return baseTexture;
|
20719
|
-
};
|
20720
|
-
|
20721
20686
|
/**
|
20722
20687
|
* Helper function that creates a base texture from the given canvas element.
|
20723
20688
|
*
|
@@ -20729,11 +20694,6 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
|
20729
20694
|
*/
|
20730
20695
|
PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
|
20731
20696
|
{
|
20732
|
-
if (!canvas._pixiId)
|
20733
|
-
{
|
20734
|
-
canvas._pixiId = 'canvas_' + PIXI.TextureCacheIdGenerator++;
|
20735
|
-
}
|
20736
|
-
|
20737
20697
|
if (canvas.width === 0)
|
20738
20698
|
{
|
20739
20699
|
canvas.width = 1;
|
@@ -20744,24 +20704,13 @@ PIXI.BaseTexture.fromCanvas = function(canvas, scaleMode)
|
|
20744
20704
|
canvas.height = 1;
|
20745
20705
|
}
|
20746
20706
|
|
20747
|
-
|
20748
|
-
|
20749
|
-
if (!baseTexture)
|
20750
|
-
{
|
20751
|
-
baseTexture = new PIXI.BaseTexture(canvas, scaleMode);
|
20752
|
-
PIXI.BaseTextureCache[canvas._pixiId] = baseTexture;
|
20753
|
-
}
|
20754
|
-
|
20755
|
-
return baseTexture;
|
20707
|
+
return new PIXI.BaseTexture(canvas, scaleMode);
|
20756
20708
|
};
|
20757
20709
|
|
20758
20710
|
/**
|
20759
20711
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
20760
20712
|
*/
|
20761
20713
|
|
20762
|
-
PIXI.TextureCache = {};
|
20763
|
-
PIXI.FrameCache = {};
|
20764
|
-
|
20765
20714
|
/**
|
20766
20715
|
* TextureSilentFail is a boolean that defaults to `false`.
|
20767
20716
|
* If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect.
|
@@ -20771,8 +20720,6 @@ PIXI.FrameCache = {};
|
|
20771
20720
|
*/
|
20772
20721
|
PIXI.TextureSilentFail = false;
|
20773
20722
|
|
20774
|
-
PIXI.TextureCacheIdGenerator = 0;
|
20775
|
-
|
20776
20723
|
/**
|
20777
20724
|
* A texture stores the information that represents an image or part of an image. It cannot be added
|
20778
20725
|
* to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used.
|
@@ -21008,46 +20955,6 @@ PIXI.Texture.prototype._updateUvs = function()
|
|
21008
20955
|
this._uvs.y3 = (frame.y + frame.height) / th;
|
21009
20956
|
};
|
21010
20957
|
|
21011
|
-
/**
|
21012
|
-
* Helper function that creates a Texture object from the given image url.
|
21013
|
-
* If the image is not in the texture cache it will be created and loaded.
|
21014
|
-
*
|
21015
|
-
* @static
|
21016
|
-
* @method fromImage
|
21017
|
-
* @param imageUrl {String} The image url of the texture
|
21018
|
-
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
|
21019
|
-
* @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
|
21020
|
-
* @return {Texture}
|
21021
|
-
*/
|
21022
|
-
PIXI.Texture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
21023
|
-
{
|
21024
|
-
var texture = PIXI.TextureCache[imageUrl];
|
21025
|
-
|
21026
|
-
if(!texture)
|
21027
|
-
{
|
21028
|
-
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin, scaleMode));
|
21029
|
-
PIXI.TextureCache[imageUrl] = texture;
|
21030
|
-
}
|
21031
|
-
|
21032
|
-
return texture;
|
21033
|
-
};
|
21034
|
-
|
21035
|
-
/**
|
21036
|
-
* Helper function that returns a Texture objected based on the given frame id.
|
21037
|
-
* If the frame id is not in the texture cache an error will be thrown.
|
21038
|
-
*
|
21039
|
-
* @static
|
21040
|
-
* @method fromFrame
|
21041
|
-
* @param frameId {String} The frame id of the texture
|
21042
|
-
* @return {Texture}
|
21043
|
-
*/
|
21044
|
-
PIXI.Texture.fromFrame = function(frameId)
|
21045
|
-
{
|
21046
|
-
var texture = PIXI.TextureCache[frameId];
|
21047
|
-
if(!texture) throw new Error('The frameId "' + frameId + '" does not exist in the texture cache ');
|
21048
|
-
return texture;
|
21049
|
-
};
|
21050
|
-
|
21051
20958
|
/**
|
21052
20959
|
* Helper function that creates a new a Texture based on the given canvas element.
|
21053
20960
|
*
|
@@ -21064,35 +20971,6 @@ PIXI.Texture.fromCanvas = function(canvas, scaleMode)
|
|
21064
20971
|
return new PIXI.Texture(baseTexture);
|
21065
20972
|
};
|
21066
20973
|
|
21067
|
-
/**
|
21068
|
-
* Adds a texture to the global PIXI.TextureCache. This cache is shared across the whole PIXI object.
|
21069
|
-
*
|
21070
|
-
* @static
|
21071
|
-
* @method addTextureToCache
|
21072
|
-
* @param texture {Texture} The Texture to add to the cache.
|
21073
|
-
* @param id {String} The id that the texture will be stored against.
|
21074
|
-
*/
|
21075
|
-
PIXI.Texture.addTextureToCache = function(texture, id)
|
21076
|
-
{
|
21077
|
-
PIXI.TextureCache[id] = texture;
|
21078
|
-
};
|
21079
|
-
|
21080
|
-
/**
|
21081
|
-
* Remove a texture from the global PIXI.TextureCache.
|
21082
|
-
*
|
21083
|
-
* @static
|
21084
|
-
* @method removeTextureFromCache
|
21085
|
-
* @param id {String} The id of the texture to be removed
|
21086
|
-
* @return {Texture} The texture that was removed
|
21087
|
-
*/
|
21088
|
-
PIXI.Texture.removeTextureFromCache = function(id)
|
21089
|
-
{
|
21090
|
-
var texture = PIXI.TextureCache[id];
|
21091
|
-
delete PIXI.TextureCache[id];
|
21092
|
-
delete PIXI.BaseTextureCache[id];
|
21093
|
-
return texture;
|
21094
|
-
};
|
21095
|
-
|
21096
20974
|
PIXI.TextureUvs = function()
|
21097
20975
|
{
|
21098
20976
|
this.x0 = 0;
|
@@ -22778,7 +22656,7 @@ var Phaser = Phaser || {
|
|
22778
22656
|
* @constant
|
22779
22657
|
* @type {string}
|
22780
22658
|
*/
|
22781
|
-
VERSION: '2.
|
22659
|
+
VERSION: '2.6.0',
|
22782
22660
|
|
22783
22661
|
/**
|
22784
22662
|
* An array of Phaser game instances.
|
@@ -23469,6 +23347,20 @@ if (!window.console)
|
|
23469
23347
|
*/
|
23470
23348
|
Phaser.Utils = {
|
23471
23349
|
|
23350
|
+
/**
|
23351
|
+
* Takes the given string and reverses it, returning the reversed string.
|
23352
|
+
* For example if given the string `Atari 520ST` it would return `TS025 iratA`.
|
23353
|
+
*
|
23354
|
+
* @method Phaser.Utils.reverseString
|
23355
|
+
* @param {string} string - The string to be reversed.
|
23356
|
+
* @return {string} The reversed string.
|
23357
|
+
*/
|
23358
|
+
reverseString: function (string) {
|
23359
|
+
|
23360
|
+
return string.split('').reverse().join('');
|
23361
|
+
|
23362
|
+
},
|
23363
|
+
|
23472
23364
|
/**
|
23473
23365
|
* Gets an objects property by string.
|
23474
23366
|
*
|
@@ -23604,14 +23496,31 @@ Phaser.Utils = {
|
|
23604
23496
|
},
|
23605
23497
|
|
23606
23498
|
/**
|
23607
|
-
*
|
23499
|
+
* Takes the given string and pads it out, to the length required, using the character
|
23500
|
+
* specified. For example if you need a string to be 6 characters long, you can call:
|
23501
|
+
*
|
23502
|
+
* `pad('bob', 6, '-', 2)`
|
23503
|
+
*
|
23504
|
+
* This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right.
|
23505
|
+
*
|
23506
|
+
* You can also use it to pad numbers (they are always returned as strings):
|
23507
|
+
*
|
23508
|
+
* `pad(512, 6, '0', 1)`
|
23509
|
+
*
|
23510
|
+
* Would return: `000512` with the string padded to the left.
|
23511
|
+
*
|
23512
|
+
* If you don't specify a direction it'll pad to both sides:
|
23513
|
+
*
|
23514
|
+
* `pad('c64', 7, '*')`
|
23515
|
+
*
|
23516
|
+
* Would return: `**c64**`
|
23608
23517
|
*
|
23609
23518
|
* @method Phaser.Utils.pad
|
23610
|
-
* @param {string} str - The target string.
|
23519
|
+
* @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers.
|
23611
23520
|
* @param {integer} [len=0] - The number of characters to be added.
|
23612
23521
|
* @param {string} [pad=" "] - The string to pad it out with (defaults to a space).
|
23613
|
-
* @param {integer} [dir=3] The direction dir = 1 (left), 2 (right), 3 (both).
|
23614
|
-
* @return {string} The padded string
|
23522
|
+
* @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both).
|
23523
|
+
* @return {string} The padded string.
|
23615
23524
|
*/
|
23616
23525
|
pad: function (str, len, pad, dir) {
|
23617
23526
|
|
@@ -23619,6 +23528,8 @@ Phaser.Utils = {
|
|
23619
23528
|
if (pad === undefined) { var pad = ' '; }
|
23620
23529
|
if (dir === undefined) { var dir = 3; }
|
23621
23530
|
|
23531
|
+
str = str.toString();
|
23532
|
+
|
23622
23533
|
var padlen = 0;
|
23623
23534
|
|
23624
23535
|
if (len + 1 >= str.length)
|
@@ -26844,6 +26755,11 @@ Phaser.Polygon = function () {
|
|
26844
26755
|
*/
|
26845
26756
|
this.closed = true;
|
26846
26757
|
|
26758
|
+
/**
|
26759
|
+
* @property {boolean} flattened - Has this Polygon been flattened by a call to `Polygon.flatten` ?
|
26760
|
+
*/
|
26761
|
+
this.flattened = false;
|
26762
|
+
|
26847
26763
|
/**
|
26848
26764
|
* @property {number} type - The base object type.
|
26849
26765
|
*/
|
@@ -26884,7 +26800,9 @@ Phaser.Polygon.prototype = {
|
|
26884
26800
|
},
|
26885
26801
|
|
26886
26802
|
/**
|
26887
|
-
* Flattens this Polygon so the points are a sequence of numbers.
|
26803
|
+
* Flattens this Polygon so the points are a sequence of numbers.
|
26804
|
+
* Any Point objects found are removed and replaced with two numbers.
|
26805
|
+
* Also sets the Polygon.flattened property to `true`.
|
26888
26806
|
*
|
26889
26807
|
* @method Phaser.Polygon#flatten
|
26890
26808
|
* @return {Phaser.Polygon} This Polygon object
|
@@ -26893,6 +26811,8 @@ Phaser.Polygon.prototype = {
|
|
26893
26811
|
|
26894
26812
|
this._points = this.toNumberArray();
|
26895
26813
|
|
26814
|
+
this.flattened = true;
|
26815
|
+
|
26896
26816
|
return this;
|
26897
26817
|
|
26898
26818
|
},
|
@@ -26934,20 +26854,39 @@ Phaser.Polygon.prototype = {
|
|
26934
26854
|
|
26935
26855
|
// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva
|
26936
26856
|
|
26937
|
-
var length = this._points.length;
|
26938
26857
|
var inside = false;
|
26939
26858
|
|
26940
|
-
|
26859
|
+
if (this.flattened)
|
26941
26860
|
{
|
26942
|
-
var
|
26943
|
-
|
26861
|
+
for (var i = -2, j = this._points.length - 2; (i += 2) < this._points.length; j = i)
|
26862
|
+
{
|
26863
|
+
var ix = this._points[i];
|
26864
|
+
var iy = this._points[i + 1];
|
26944
26865
|
|
26945
|
-
|
26946
|
-
|
26866
|
+
var jx = this._points[j];
|
26867
|
+
var jy = this._points[j + 1];
|
26868
|
+
|
26869
|
+
if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix))
|
26870
|
+
{
|
26871
|
+
inside = !inside;
|
26872
|
+
}
|
26873
|
+
}
|
26947
26874
|
|
26948
|
-
|
26875
|
+
}
|
26876
|
+
else
|
26877
|
+
{
|
26878
|
+
for (var i = -1, j = this._points.length - 1; ++i < this._points.length; j = i)
|
26949
26879
|
{
|
26950
|
-
|
26880
|
+
var ix = this._points[i].x;
|
26881
|
+
var iy = this._points[i].y;
|
26882
|
+
|
26883
|
+
var jx = this._points[j].x;
|
26884
|
+
var jy = this._points[j].y;
|
26885
|
+
|
26886
|
+
if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix))
|
26887
|
+
{
|
26888
|
+
inside = !inside;
|
26889
|
+
}
|
26951
26890
|
}
|
26952
26891
|
}
|
26953
26892
|
|
@@ -32795,6 +32734,8 @@ Phaser.Group.prototype.align = function (rows, columns, cellWidth, cellHeight, p
|
|
32795
32734
|
else
|
32796
32735
|
{
|
32797
32736
|
// We keep laying them out until we hit the column limit
|
32737
|
+
r.x += cellWidth;
|
32738
|
+
|
32798
32739
|
if (r.x === w)
|
32799
32740
|
{
|
32800
32741
|
r.x = 0;
|
@@ -34225,17 +34166,24 @@ Phaser.Group.prototype.getBottom = function () {
|
|
34225
34166
|
};
|
34226
34167
|
|
34227
34168
|
/**
|
34228
|
-
* Get the closest child to given Object.
|
34169
|
+
* Get the closest child to given Object, with optional callback to filter children.
|
34229
34170
|
*
|
34230
34171
|
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
34231
34172
|
*
|
34232
34173
|
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
34233
34174
|
*
|
34175
|
+
* You can use the optional `callback` argument to apply your own filter to the distance checks.
|
34176
|
+
* If the child is closer then the previous child, it will be sent to `callback` as the first argument,
|
34177
|
+
* with the distance as the second. The callback should return `true` if it passes your
|
34178
|
+
* filtering criteria, otherwise it should return `false`.
|
34179
|
+
*
|
34234
34180
|
* @method Phaser.Group#getClosestTo
|
34235
34181
|
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
34236
|
-
* @
|
34182
|
+
* @param {function} [callback] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria.
|
34183
|
+
* @param {object} [callbackContext] - The context in which the function should be called (usually 'this').
|
34184
|
+
* @return {any} The child closest to given object, or `null` if no child was found.
|
34237
34185
|
*/
|
34238
|
-
Phaser.Group.prototype.getClosestTo = function (object) {
|
34186
|
+
Phaser.Group.prototype.getClosestTo = function (object, callback, callbackContext) {
|
34239
34187
|
|
34240
34188
|
var distance = Number.MAX_VALUE;
|
34241
34189
|
var tempDistance = 0;
|
@@ -34249,7 +34197,7 @@ Phaser.Group.prototype.getClosestTo = function (object) {
|
|
34249
34197
|
{
|
34250
34198
|
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
34251
34199
|
|
34252
|
-
if (tempDistance < distance)
|
34200
|
+
if (tempDistance < distance && (!callback || callback.call(callbackContext, child, tempDistance)))
|
34253
34201
|
{
|
34254
34202
|
distance = tempDistance;
|
34255
34203
|
result = child;
|
@@ -34262,17 +34210,24 @@ Phaser.Group.prototype.getClosestTo = function (object) {
|
|
34262
34210
|
};
|
34263
34211
|
|
34264
34212
|
/**
|
34265
|
-
* Get the child furthest away from the given Object.
|
34213
|
+
* Get the child furthest away from the given Object, with optional callback to filter children.
|
34266
34214
|
*
|
34267
34215
|
* This can be a Sprite, Group, Image or any object with public x and y properties.
|
34268
34216
|
*
|
34269
34217
|
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
34270
34218
|
*
|
34219
|
+
* You can use the optional `callback` argument to apply your own filter to the distance checks.
|
34220
|
+
* If the child is closer then the previous child, it will be sent to `callback` as the first argument,
|
34221
|
+
* with the distance as the second. The callback should return `true` if it passes your
|
34222
|
+
* filtering criteria, otherwise it should return `false`.
|
34223
|
+
*
|
34271
34224
|
* @method Phaser.Group#getFurthestFrom
|
34272
34225
|
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
34273
|
-
* @
|
34226
|
+
* @param {function} [callback] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria.
|
34227
|
+
* @param {object} [callbackContext] - The context in which the function should be called (usually 'this').
|
34228
|
+
* @return {any} The child furthest from the given object, or `null` if no child was found.
|
34274
34229
|
*/
|
34275
|
-
Phaser.Group.prototype.getFurthestFrom = function (object) {
|
34230
|
+
Phaser.Group.prototype.getFurthestFrom = function (object, callback, callbackContext) {
|
34276
34231
|
|
34277
34232
|
var distance = 0;
|
34278
34233
|
var tempDistance = 0;
|
@@ -34286,7 +34241,7 @@ Phaser.Group.prototype.getFurthestFrom = function (object) {
|
|
34286
34241
|
{
|
34287
34242
|
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
34288
34243
|
|
34289
|
-
if (tempDistance > distance)
|
34244
|
+
if (tempDistance > distance && (!callback || callback.call(callbackContext, child, tempDistance)))
|
34290
34245
|
{
|
34291
34246
|
distance = tempDistance;
|
34292
34247
|
result = child;
|
@@ -34618,6 +34573,289 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
|
34618
34573
|
|
34619
34574
|
});
|
34620
34575
|
|
34576
|
+
/**
|
34577
|
+
* The center x coordinate of this Group.
|
34578
|
+
*
|
34579
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34580
|
+
* visible children.
|
34581
|
+
*
|
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
|
+
* @name Phaser.Group#centerX
|
34588
|
+
* @property {number} centerX
|
34589
|
+
*/
|
34590
|
+
Object.defineProperty(Phaser.Group.prototype, "centerX", {
|
34591
|
+
|
34592
|
+
get: function () {
|
34593
|
+
|
34594
|
+
return this.getBounds().centerX;
|
34595
|
+
|
34596
|
+
},
|
34597
|
+
|
34598
|
+
set: function (value) {
|
34599
|
+
|
34600
|
+
var r = this.getBounds();
|
34601
|
+
var offset = this.x - r.x;
|
34602
|
+
|
34603
|
+
this.x = (value + offset) - r.halfWidth;
|
34604
|
+
|
34605
|
+
}
|
34606
|
+
|
34607
|
+
});
|
34608
|
+
|
34609
|
+
/**
|
34610
|
+
* The center y coordinate of this Group.
|
34611
|
+
*
|
34612
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34613
|
+
* visible children.
|
34614
|
+
*
|
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
|
+
* @name Phaser.Group#centerY
|
34621
|
+
* @property {number} centerY
|
34622
|
+
*/
|
34623
|
+
Object.defineProperty(Phaser.Group.prototype, "centerY", {
|
34624
|
+
|
34625
|
+
get: function () {
|
34626
|
+
|
34627
|
+
return this.getBounds().centerY;
|
34628
|
+
|
34629
|
+
},
|
34630
|
+
|
34631
|
+
set: function (value) {
|
34632
|
+
|
34633
|
+
var r = this.getBounds();
|
34634
|
+
var offset = this.y - r.y;
|
34635
|
+
|
34636
|
+
this.y = (value + offset) - r.halfHeight;
|
34637
|
+
|
34638
|
+
}
|
34639
|
+
|
34640
|
+
});
|
34641
|
+
|
34642
|
+
/**
|
34643
|
+
* The left coordinate of this Group.
|
34644
|
+
*
|
34645
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34646
|
+
* visible children.
|
34647
|
+
*
|
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
|
+
* @name Phaser.Group#left
|
34654
|
+
* @property {number} left
|
34655
|
+
*/
|
34656
|
+
Object.defineProperty(Phaser.Group.prototype, "left", {
|
34657
|
+
|
34658
|
+
get: function () {
|
34659
|
+
|
34660
|
+
return this.getBounds().left;
|
34661
|
+
|
34662
|
+
},
|
34663
|
+
|
34664
|
+
set: function (value) {
|
34665
|
+
|
34666
|
+
var r = this.getBounds();
|
34667
|
+
var offset = this.x - r.x;
|
34668
|
+
|
34669
|
+
this.x = value + offset;
|
34670
|
+
|
34671
|
+
}
|
34672
|
+
|
34673
|
+
});
|
34674
|
+
|
34675
|
+
/**
|
34676
|
+
* The right coordinate of this Group.
|
34677
|
+
*
|
34678
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34679
|
+
* 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
|
+
*
|
34686
|
+
* @name Phaser.Group#right
|
34687
|
+
* @property {number} right
|
34688
|
+
*/
|
34689
|
+
Object.defineProperty(Phaser.Group.prototype, "right", {
|
34690
|
+
|
34691
|
+
get: function () {
|
34692
|
+
|
34693
|
+
return this.getBounds().right;
|
34694
|
+
|
34695
|
+
},
|
34696
|
+
|
34697
|
+
set: function (value) {
|
34698
|
+
|
34699
|
+
var r = this.getBounds();
|
34700
|
+
var offset = this.x - r.x;
|
34701
|
+
|
34702
|
+
this.x = (value + offset) - r.width;
|
34703
|
+
|
34704
|
+
}
|
34705
|
+
|
34706
|
+
});
|
34707
|
+
|
34708
|
+
/**
|
34709
|
+
* The top coordinate of this Group.
|
34710
|
+
*
|
34711
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34712
|
+
* 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
|
+
*
|
34719
|
+
* @name Phaser.Group#top
|
34720
|
+
* @property {number} top
|
34721
|
+
*/
|
34722
|
+
Object.defineProperty(Phaser.Group.prototype, "top", {
|
34723
|
+
|
34724
|
+
get: function () {
|
34725
|
+
|
34726
|
+
return this.getBounds().top;
|
34727
|
+
|
34728
|
+
},
|
34729
|
+
|
34730
|
+
set: function (value) {
|
34731
|
+
|
34732
|
+
var r = this.getBounds();
|
34733
|
+
var offset = this.y - r.y;
|
34734
|
+
|
34735
|
+
this.y = (value + offset);
|
34736
|
+
|
34737
|
+
}
|
34738
|
+
|
34739
|
+
});
|
34740
|
+
|
34741
|
+
/**
|
34742
|
+
* The bottom coordinate of this Group.
|
34743
|
+
*
|
34744
|
+
* It is derived by calling `getBounds`, calculating the Groups dimensions based on its
|
34745
|
+
* visible children.
|
34746
|
+
*
|
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
|
+
* @name Phaser.Group#bottom
|
34753
|
+
* @property {number} bottom
|
34754
|
+
*/
|
34755
|
+
Object.defineProperty(Phaser.Group.prototype, "bottom", {
|
34756
|
+
|
34757
|
+
get: function () {
|
34758
|
+
|
34759
|
+
return this.getBounds().bottom;
|
34760
|
+
|
34761
|
+
},
|
34762
|
+
|
34763
|
+
set: function (value) {
|
34764
|
+
|
34765
|
+
var r = this.getBounds();
|
34766
|
+
var offset = this.y - r.y;
|
34767
|
+
|
34768
|
+
this.y = (value + offset) - r.height;
|
34769
|
+
|
34770
|
+
}
|
34771
|
+
|
34772
|
+
});
|
34773
|
+
|
34774
|
+
/**
|
34775
|
+
* Aligns this Group within another Game Object, or Rectangle, known as the
|
34776
|
+
* 'container', to one of 9 possible positions.
|
34777
|
+
*
|
34778
|
+
* The container must be a Game Object, or Phaser.Rectangle object. This can include properties
|
34779
|
+
* such as `World.bounds` or `Camera.view`, for aligning Groups within the world
|
34780
|
+
* and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText,
|
34781
|
+
* TileSprites or Buttons.
|
34782
|
+
*
|
34783
|
+
* Please note that aligning a Group to another Game Object does **not** make it a child of
|
34784
|
+
* the container. It simply modifies its position coordinates so it aligns with it.
|
34785
|
+
*
|
34786
|
+
* The position constants you can use are:
|
34787
|
+
*
|
34788
|
+
* `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_CENTER`,
|
34789
|
+
* `Phaser.CENTER`, `Phaser.RIGHT_CENTER`, `Phaser.BOTTOM_LEFT`,
|
34790
|
+
* `Phaser.BOTTOM_CENTER` and `Phaser.BOTTOM_RIGHT`.
|
34791
|
+
*
|
34792
|
+
* Groups are placed in such a way that their _bounds_ align with the
|
34793
|
+
* container, taking into consideration rotation and scale of its children.
|
34794
|
+
* This allows you to neatly align Groups, irrespective of their position value.
|
34795
|
+
*
|
34796
|
+
* The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final
|
34797
|
+
* aligned position of the Group. For example:
|
34798
|
+
*
|
34799
|
+
* `group.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)`
|
34800
|
+
*
|
34801
|
+
* Would align the `group` to the bottom-right, but moved 20 pixels in from the corner.
|
34802
|
+
* Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place.
|
34803
|
+
* So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive
|
34804
|
+
* one expands it.
|
34805
|
+
*
|
34806
|
+
* @method Phaser.Group#alignIn
|
34807
|
+
* @param {Phaser.Rectangle|Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapText|Phaser.Button|Phaser.Graphics|Phaser.TileSprite} container - The Game Object or Rectangle with which to align this Group to. Can also include properties such as `World.bounds` or `Camera.view`.
|
34808
|
+
* @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`.
|
34809
|
+
* @param {integer} [offsetX=0] - A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.
|
34810
|
+
* @param {integer} [offsetY=0] - A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.
|
34811
|
+
* @return {Phaser.Group} This Group.
|
34812
|
+
*/
|
34813
|
+
|
34814
|
+
// This function is set at the bottom of src/gameobjects/components/Bounds.js
|
34815
|
+
|
34816
|
+
/**
|
34817
|
+
* Aligns this Group to the side of another Game Object, or Rectangle, known as the
|
34818
|
+
* 'parent', in one of 11 possible positions.
|
34819
|
+
*
|
34820
|
+
* The parent must be a Game Object, or Phaser.Rectangle object. This can include properties
|
34821
|
+
* such as `World.bounds` or `Camera.view`, for aligning Groups within the world
|
34822
|
+
* and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText,
|
34823
|
+
* TileSprites or Buttons.
|
34824
|
+
*
|
34825
|
+
* Please note that aligning a Group to another Game Object does **not** make it a child of
|
34826
|
+
* the parent. It simply modifies its position coordinates so it aligns with it.
|
34827
|
+
*
|
34828
|
+
* The position constants you can use are:
|
34829
|
+
*
|
34830
|
+
* `Phaser.TOP_LEFT` (default), `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`,
|
34831
|
+
* `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`,
|
34832
|
+
* `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER`
|
34833
|
+
* and `Phaser.BOTTOM_RIGHT`.
|
34834
|
+
*
|
34835
|
+
* Groups are placed in such a way that their _bounds_ align with the
|
34836
|
+
* parent, taking into consideration rotation and scale of the children.
|
34837
|
+
* This allows you to neatly align Groups, irrespective of their position value.
|
34838
|
+
*
|
34839
|
+
* The optional `offsetX` and `offsetY` arguments allow you to apply extra spacing to the final
|
34840
|
+
* aligned position of the Group. For example:
|
34841
|
+
*
|
34842
|
+
* `group.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)`
|
34843
|
+
*
|
34844
|
+
* Would align the `group` to the bottom-right, but moved 20 pixels in from the corner.
|
34845
|
+
* Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place.
|
34846
|
+
* So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive
|
34847
|
+
* one expands it.
|
34848
|
+
*
|
34849
|
+
* @method Phaser.Group#alignTo
|
34850
|
+
* @param {Phaser.Rectangle|Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapText|Phaser.Button|Phaser.Graphics|Phaser.TileSprite} parent - The Game Object or Rectangle with which to align this Group to. Can also include properties such as `World.bounds` or `Camera.view`.
|
34851
|
+
* @param {integer} [position] - The position constant. One of `Phaser.TOP_LEFT`, `Phaser.TOP_CENTER`, `Phaser.TOP_RIGHT`, `Phaser.LEFT_TOP`, `Phaser.LEFT_CENTER`, `Phaser.LEFT_BOTTOM`, `Phaser.RIGHT_TOP`, `Phaser.RIGHT_CENTER`, `Phaser.RIGHT_BOTTOM`, `Phaser.BOTTOM_LEFT`, `Phaser.BOTTOM_CENTER` or `Phaser.BOTTOM_RIGHT`.
|
34852
|
+
* @param {integer} [offsetX=0] - A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.
|
34853
|
+
* @param {integer} [offsetY=0] - A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.
|
34854
|
+
* @return {Phaser.Group} This Group.
|
34855
|
+
*/
|
34856
|
+
|
34857
|
+
// This function is set at the bottom of src/gameobjects/components/Bounds.js
|
34858
|
+
|
34621
34859
|
/**
|
34622
34860
|
* A display object is any object that can be rendered in the Phaser/pixi.js scene graph.
|
34623
34861
|
*
|
@@ -40887,9 +41125,10 @@ Phaser.InputHandler.prototype = {
|
|
40887
41125
|
|
40888
41126
|
/**
|
40889
41127
|
* Starts the Input Handler running. This is called automatically when you enable input on a Sprite, or can be called directly if you need to set a specific priority.
|
41128
|
+
*
|
40890
41129
|
* @method Phaser.InputHandler#start
|
40891
|
-
* @param {number} priority - Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other.
|
40892
|
-
* @param {boolean} useHandCursor - If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers)
|
41130
|
+
* @param {number} [priority=0] - Higher priority sprites take click priority over low-priority sprites when they are stacked on-top of each other.
|
41131
|
+
* @param {boolean} [useHandCursor=false] - If true the Sprite will show the hand cursor on mouse-over (doesn't apply to mobile browsers)
|
40893
41132
|
* @return {Phaser.Sprite} The Sprite object to which the Input Handler is bound.
|
40894
41133
|
*/
|
40895
41134
|
start: function (priority, useHandCursor) {
|
@@ -41510,7 +41749,7 @@ Phaser.InputHandler.prototype = {
|
|
41510
41749
|
}
|
41511
41750
|
else if (this.draggable && this._draggedPointerID === pointer.id)
|
41512
41751
|
{
|
41513
|
-
return this.updateDrag(pointer);
|
41752
|
+
return this.updateDrag(pointer, false);
|
41514
41753
|
}
|
41515
41754
|
else if (this._pointerData[pointer.id].isOver)
|
41516
41755
|
{
|
@@ -41789,24 +42028,24 @@ Phaser.InputHandler.prototype = {
|
|
41789
42028
|
},
|
41790
42029
|
|
41791
42030
|
/**
|
41792
|
-
*
|
42031
|
+
* Called as a Pointer actively drags this Game Object.
|
42032
|
+
*
|
41793
42033
|
* @method Phaser.InputHandler#updateDrag
|
41794
|
-
* @
|
42034
|
+
* @private
|
42035
|
+
* @param {Phaser.Pointer} pointer - The Pointer causing the drag update.
|
42036
|
+
* @param {boolean} fromStart - True if this is the first update, immediately after the drag has started.
|
41795
42037
|
* @return {boolean}
|
41796
42038
|
*/
|
41797
42039
|
updateDrag: function (pointer, fromStart) {
|
41798
42040
|
|
42041
|
+
if (fromStart === undefined) { fromStart = false; }
|
42042
|
+
|
41799
42043
|
if (pointer.isUp)
|
41800
42044
|
{
|
41801
42045
|
this.stopDrag(pointer);
|
41802
42046
|
return false;
|
41803
42047
|
}
|
41804
42048
|
|
41805
|
-
if (fromStart === undefined)
|
41806
|
-
{
|
41807
|
-
fromStart = false;
|
41808
|
-
}
|
41809
|
-
|
41810
42049
|
var px = this.globalToLocalX(pointer.x) + this._dragPoint.x + this.dragOffset.x;
|
41811
42050
|
var py = this.globalToLocalY(pointer.y) + this._dragPoint.y + this.dragOffset.y;
|
41812
42051
|
|
@@ -42257,7 +42496,6 @@ Phaser.InputHandler.prototype = {
|
|
42257
42496
|
|
42258
42497
|
},
|
42259
42498
|
|
42260
|
-
|
42261
42499
|
/**
|
42262
42500
|
* Bounds Rect check for the sprite drag
|
42263
42501
|
*
|
@@ -45322,6 +45560,11 @@ Phaser.Component.Bounds.prototype = {
|
|
45322
45560
|
|
45323
45561
|
};
|
45324
45562
|
|
45563
|
+
// Phaser.Group extensions
|
45564
|
+
|
45565
|
+
Phaser.Group.prototype.alignIn = Phaser.Component.Bounds.prototype.alignIn;
|
45566
|
+
Phaser.Group.prototype.alignTo = Phaser.Component.Bounds.prototype.alignTo;
|
45567
|
+
|
45325
45568
|
/**
|
45326
45569
|
* @author Richard Davey <rich@photonstorm.com>
|
45327
45570
|
* @copyright 2016 Photon Storm Ltd.
|
@@ -46141,7 +46384,7 @@ Phaser.Component.Destroy.prototype = {
|
|
46141
46384
|
*/
|
46142
46385
|
|
46143
46386
|
/**
|
46144
|
-
* The Events component is a collection of events fired by the parent
|
46387
|
+
* The Events component is a collection of events fired by the parent Game Object.
|
46145
46388
|
*
|
46146
46389
|
* Phaser uses what are known as 'Signals' for all event handling. All of the events in
|
46147
46390
|
* this class are signals you can subscribe to, much in the same way you'd "listen" for
|
@@ -46211,92 +46454,187 @@ Phaser.Events.prototype = {
|
|
46211
46454
|
// The following properties are sentinels that will be replaced with getters
|
46212
46455
|
|
46213
46456
|
/**
|
46214
|
-
*
|
46457
|
+
* This signal is dispatched when this Game Object is added to a new Group.
|
46458
|
+
* It is sent two arguments:
|
46459
|
+
* {any} The Game Object that was added to the Group.
|
46460
|
+
* {Phaser.Group} The Group it was added to.
|
46461
|
+
* @property {Phaser.Signal} onAddedToGroup
|
46215
46462
|
*/
|
46216
46463
|
onAddedToGroup: null,
|
46217
46464
|
|
46218
46465
|
/**
|
46219
|
-
*
|
46466
|
+
* This signal is dispatched when the Game Object is removed from a Group.
|
46467
|
+
* It is sent two arguments:
|
46468
|
+
* {any} The Game Object that was removed from the Group.
|
46469
|
+
* {Phaser.Group} The Group it was removed from.
|
46470
|
+
* @property {Phaser.Signal} onRemovedFromGroup
|
46220
46471
|
*/
|
46221
46472
|
onRemovedFromGroup: null,
|
46222
46473
|
|
46223
46474
|
/**
|
46224
|
-
*
|
46475
|
+
* This Signal is never used internally by Phaser and is now deprecated.
|
46476
|
+
* @deprecated
|
46477
|
+
* @property {Phaser.Signal} onRemovedFromWorld
|
46225
46478
|
*/
|
46226
46479
|
onRemovedFromWorld: null,
|
46227
46480
|
|
46228
46481
|
/**
|
46229
|
-
*
|
46482
|
+
* This signal is dispatched when the Game Object is destroyed.
|
46483
|
+
* This happens when `Sprite.destroy()` is called, or `Group.destroy()` with `destroyChildren` set to true.
|
46484
|
+
* It is sent one argument:
|
46485
|
+
* {any} The Game Object that was destroyed.
|
46486
|
+
* @property {Phaser.Signal} onDestroy
|
46230
46487
|
*/
|
46231
46488
|
onDestroy: null,
|
46232
46489
|
|
46233
46490
|
/**
|
46234
|
-
*
|
46491
|
+
* This signal is dispatched when the Game Object is killed.
|
46492
|
+
* This happens when `Sprite.kill()` is called.
|
46493
|
+
* Please understand the difference between `kill` and `destroy` by looking at their respective methods.
|
46494
|
+
* It is sent one argument:
|
46495
|
+
* {any} The Game Object that was killed.
|
46496
|
+
* @property {Phaser.Signal} onKilled
|
46235
46497
|
*/
|
46236
46498
|
onKilled: null,
|
46237
46499
|
|
46238
46500
|
/**
|
46239
|
-
*
|
46501
|
+
* This signal is dispatched when the Game Object is revived from a previously killed state.
|
46502
|
+
* This happens when `Sprite.revive()` is called.
|
46503
|
+
* It is sent one argument:
|
46504
|
+
* {any} The Game Object that was revived.
|
46505
|
+
* @property {Phaser.Signal} onRevived
|
46240
46506
|
*/
|
46241
46507
|
onRevived: null,
|
46242
46508
|
|
46243
46509
|
/**
|
46244
|
-
*
|
46510
|
+
* This signal is dispatched when the Game Object leaves the Phaser.World bounds.
|
46511
|
+
* This signal is only if `Sprite.checkWorldBounds` is set to `true`.
|
46512
|
+
* It is sent one argument:
|
46513
|
+
* {any} The Game Object that left the World bounds.
|
46514
|
+
* @property {Phaser.Signal} onOutOfBounds
|
46245
46515
|
*/
|
46246
46516
|
onOutOfBounds: null,
|
46247
46517
|
|
46248
46518
|
/**
|
46249
|
-
*
|
46519
|
+
* This signal is dispatched when the Game Object returns within the Phaser.World bounds, having previously been outside of them.
|
46520
|
+
* This signal is only if `Sprite.checkWorldBounds` is set to `true`.
|
46521
|
+
* It is sent one argument:
|
46522
|
+
* {any} The Game Object that entered the World bounds.
|
46523
|
+
* @property {Phaser.Signal} onEnterBounds
|
46250
46524
|
*/
|
46251
46525
|
onEnterBounds: null,
|
46252
46526
|
|
46253
46527
|
/**
|
46254
|
-
*
|
46528
|
+
* This signal is dispatched if the Game Object has `inputEnabled` set to `true`,
|
46529
|
+
* and receives an over event from a Phaser.Pointer.
|
46530
|
+
* It is sent two arguments:
|
46531
|
+
* {any} The Game Object that received the event.
|
46532
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46533
|
+
* @property {Phaser.Signal} onInputOver
|
46255
46534
|
*/
|
46256
46535
|
onInputOver: null,
|
46257
46536
|
|
46258
46537
|
/**
|
46259
|
-
*
|
46538
|
+
* This signal is dispatched if the Game Object has `inputEnabled` set to `true`,
|
46539
|
+
* and receives an out event from a Phaser.Pointer, which was previously over it.
|
46540
|
+
* It is sent two arguments:
|
46541
|
+
* {any} The Game Object that received the event.
|
46542
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46543
|
+
* @property {Phaser.Signal} onInputOut
|
46260
46544
|
*/
|
46261
46545
|
onInputOut: null,
|
46262
46546
|
|
46263
46547
|
/**
|
46264
|
-
*
|
46548
|
+
* This signal is dispatched if the Game Object has `inputEnabled` set to `true`,
|
46549
|
+
* and receives a down event from a Phaser.Pointer. This effectively means the Pointer has been
|
46550
|
+
* pressed down (but not yet released) on the Game Object.
|
46551
|
+
* It is sent two arguments:
|
46552
|
+
* {any} The Game Object that received the event.
|
46553
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46554
|
+
* @property {Phaser.Signal} onInputDown
|
46265
46555
|
*/
|
46266
46556
|
onInputDown: null,
|
46267
46557
|
|
46268
46558
|
/**
|
46269
|
-
*
|
46559
|
+
* This signal is dispatched if the Game Object has `inputEnabled` set to `true`,
|
46560
|
+
* and receives an up event from a Phaser.Pointer. This effectively means the Pointer had been
|
46561
|
+
* pressed down, and was then released on the Game Object.
|
46562
|
+
* It is sent three arguments:
|
46563
|
+
* {any} The Game Object that received the event.
|
46564
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46565
|
+
* {boolean} isOver - Is the Pointer still over the Game Object?
|
46566
|
+
* @property {Phaser.Signal} onInputUp
|
46270
46567
|
*/
|
46271
46568
|
onInputUp: null,
|
46272
46569
|
|
46273
46570
|
/**
|
46274
|
-
*
|
46571
|
+
* This signal is dispatched if the Game Object has been `inputEnabled` and `enableDrag` has been set.
|
46572
|
+
* It is sent when a Phaser.Pointer starts to drag the Game Object, taking into consideration the various
|
46573
|
+
* drag limitations that may be set.
|
46574
|
+
* It is sent four arguments:
|
46575
|
+
* {any} The Game Object that received the event.
|
46576
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46577
|
+
* {number} The x coordinate that the drag started from.
|
46578
|
+
* {number} The y coordinate that the drag started from.
|
46579
|
+
* @property {Phaser.Signal} onDragStart
|
46275
46580
|
*/
|
46276
46581
|
onDragStart: null,
|
46277
46582
|
|
46278
46583
|
/**
|
46279
|
-
*
|
46584
|
+
* This signal is dispatched if the Game Object has been `inputEnabled` and `enableDrag` has been set.
|
46585
|
+
* It is sent when a Phaser.Pointer is actively dragging the Game Object.
|
46586
|
+
* Be warned: This is a high volume Signal. Be careful what you bind to it.
|
46587
|
+
* It is sent six arguments:
|
46588
|
+
* {any} The Game Object that received the event.
|
46589
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46590
|
+
* {number} The new x coordinate of the Game Object.
|
46591
|
+
* {number} The new y coordinate of the Game Object.
|
46592
|
+
* {Phaser.Point} A Point object that contains the point the Game Object was snapped to, if `snapOnDrag` has been enabled.
|
46593
|
+
* {boolean} The `fromStart` boolean, indicates if this is the first update immediately after the drag has started.
|
46594
|
+
* @property {Phaser.Signal} onDragUpdate
|
46280
46595
|
*/
|
46281
46596
|
onDragUpdate: null,
|
46282
46597
|
|
46283
46598
|
/**
|
46284
|
-
*
|
46599
|
+
* This signal is dispatched if the Game Object has been `inputEnabled` and `enableDrag` has been set.
|
46600
|
+
* It is sent when a Phaser.Pointer stops dragging the Game Object.
|
46601
|
+
* It is sent two arguments:
|
46602
|
+
* {any} The Game Object that received the event.
|
46603
|
+
* {Phaser.Pointer} The Phaser.Pointer object that caused the event.
|
46604
|
+
* @property {Phaser.Signal} onDragStop
|
46285
46605
|
*/
|
46286
46606
|
onDragStop: null,
|
46287
46607
|
|
46288
46608
|
/**
|
46289
|
-
*
|
46609
|
+
* This signal is dispatched if the Game Object has the AnimationManager component,
|
46610
|
+
* and an Animation has been played.
|
46611
|
+
* You can also listen to `Animation.onStart` rather than via the Game Objects events.
|
46612
|
+
* It is sent two arguments:
|
46613
|
+
* {any} The Game Object that received the event.
|
46614
|
+
* {Phaser.Animation} The Phaser.Animation that was started.
|
46615
|
+
* @property {Phaser.Signal} onAnimationStart
|
46290
46616
|
*/
|
46291
46617
|
onAnimationStart: null,
|
46292
46618
|
|
46293
46619
|
/**
|
46294
|
-
*
|
46620
|
+
* This signal is dispatched if the Game Object has the AnimationManager component,
|
46621
|
+
* and an Animation has been stopped (via `animation.stop()` and the `dispatchComplete` argument has been set.
|
46622
|
+
* You can also listen to `Animation.onComplete` rather than via the Game Objects events.
|
46623
|
+
* It is sent two arguments:
|
46624
|
+
* {any} The Game Object that received the event.
|
46625
|
+
* {Phaser.Animation} The Phaser.Animation that was stopped.
|
46626
|
+
* @property {Phaser.Signal} onAnimationComplete
|
46295
46627
|
*/
|
46296
46628
|
onAnimationComplete: null,
|
46297
46629
|
|
46298
46630
|
/**
|
46299
|
-
*
|
46631
|
+
* This signal is dispatched if the Game Object has the AnimationManager component,
|
46632
|
+
* and an Animation has looped playback.
|
46633
|
+
* You can also listen to `Animation.onLoop` rather than via the Game Objects events.
|
46634
|
+
* It is sent two arguments:
|
46635
|
+
* {any} The Game Object that received the event.
|
46636
|
+
* {Phaser.Animation} The Phaser.Animation that looped.
|
46637
|
+
* @property {Phaser.Signal} onAnimationLoop
|
46300
46638
|
*/
|
46301
46639
|
onAnimationLoop: null
|
46302
46640
|
|
@@ -46602,6 +46940,10 @@ Phaser.Component.InputEnabled.prototype = {
|
|
46602
46940
|
* Note that Input related events are dispatched from `this.events`, i.e.: `events.onInputDown`.
|
46603
46941
|
*
|
46604
46942
|
* If you set this property to false it will stop the Input Handler from processing any more input events.
|
46943
|
+
*
|
46944
|
+
* If you want to _temporarily_ disable input for a Game Object, then it's better to set
|
46945
|
+
* `input.enabled = false`, as it won't reset any of the Input Handlers internal properties.
|
46946
|
+
* You can then toggle this back on as needed.
|
46605
46947
|
*
|
46606
46948
|
* @property {boolean} inputEnabled
|
46607
46949
|
*/
|
@@ -48755,7 +49097,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|
48755
49097
|
*/
|
48756
49098
|
this.physicsType = Phaser.SPRITE;
|
48757
49099
|
|
48758
|
-
PIXI.Sprite.call(this,
|
49100
|
+
PIXI.Sprite.call(this, Phaser.Cache.DEFAULT);
|
48759
49101
|
|
48760
49102
|
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
|
48761
49103
|
|
@@ -48857,7 +49199,7 @@ Phaser.Image = function (game, x, y, key, frame) {
|
|
48857
49199
|
*/
|
48858
49200
|
this.type = Phaser.IMAGE;
|
48859
49201
|
|
48860
|
-
PIXI.Sprite.call(this,
|
49202
|
+
PIXI.Sprite.call(this, Phaser.Cache.DEFAULT);
|
48861
49203
|
|
48862
49204
|
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
|
48863
49205
|
|
@@ -49562,11 +49904,13 @@ Phaser.SpriteBatch.prototype.constructor = Phaser.SpriteBatch;
|
|
49562
49904
|
* @param {string} key - Internal Phaser reference key for the BitmapData.
|
49563
49905
|
* @param {number} [width=256] - The width of the BitmapData in pixels. If undefined or zero it's set to a default value.
|
49564
49906
|
* @param {number} [height=256] - The height of the BitmapData in pixels. If undefined or zero it's set to a default value.
|
49907
|
+
* @param {boolean} [skipPool=false] - When this BitmapData generates its internal canvas to use for rendering, it will get the canvas from the CanvasPool if false, or create its own if true.
|
49565
49908
|
*/
|
49566
|
-
Phaser.BitmapData = function (game, key, width, height) {
|
49909
|
+
Phaser.BitmapData = function (game, key, width, height, skipPool) {
|
49567
49910
|
|
49568
49911
|
if (width === undefined || width === 0) { width = 256; }
|
49569
49912
|
if (height === undefined || height === 0) { height = 256; }
|
49913
|
+
if (skipPool === undefined) { skipPool = false; }
|
49570
49914
|
|
49571
49915
|
/**
|
49572
49916
|
* @property {Phaser.Game} game - A reference to the currently running game.
|
@@ -49592,7 +49936,7 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|
49592
49936
|
* @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws.
|
49593
49937
|
* @default
|
49594
49938
|
*/
|
49595
|
-
this.canvas =
|
49939
|
+
this.canvas = Phaser.Canvas.create(this, width, height, null, skipPool);
|
49596
49940
|
|
49597
49941
|
/**
|
49598
49942
|
* @property {CanvasRenderingContext2D} context - The 2d context of the canvas.
|
@@ -51094,7 +51438,13 @@ Phaser.BitmapData.prototype = {
|
|
51094
51438
|
/**
|
51095
51439
|
* Draws the given Phaser.Sprite, Phaser.Image or Phaser.Text to this BitmapData at the coordinates specified.
|
51096
51440
|
* You can use the optional width and height values to 'stretch' the sprite as it is drawn. This uses drawImage stretching, not scaling.
|
51097
|
-
*
|
51441
|
+
*
|
51442
|
+
* The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be visible.
|
51443
|
+
* When drawing it will take into account the rotation, scale, scaleMode, alpha and tint values.
|
51444
|
+
*
|
51445
|
+
* Note: You should ensure that at least 1 full update has taken place before calling this,
|
51446
|
+
* otherwise the objects are likely to render incorrectly, if at all.
|
51447
|
+
* You can trigger an update yourself by calling `stage.updateTransform()` before calling `draw`.
|
51098
51448
|
*
|
51099
51449
|
* @method Phaser.BitmapData#draw
|
51100
51450
|
* @param {Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.RenderTexture} source - The Sprite, Image or Text object to draw onto this BitmapData.
|
@@ -51125,7 +51475,7 @@ Phaser.BitmapData.prototype = {
|
|
51125
51475
|
*
|
51126
51476
|
* Note: You should ensure that at least 1 full update has taken place before calling this,
|
51127
51477
|
* otherwise the objects are likely to render incorrectly, if at all.
|
51128
|
-
* You can
|
51478
|
+
* You can trigger an update yourself by calling `stage.updateTransform()` before calling `drawGroup`.
|
51129
51479
|
*
|
51130
51480
|
* @method Phaser.BitmapData#drawGroup
|
51131
51481
|
* @param {Phaser.Group} group - The Group to draw onto this BitmapData. Can also be Phaser.World.
|
@@ -52179,6 +52529,7 @@ PIXI.Graphics.prototype.lineTo = function(x, y)
|
|
52179
52529
|
|
52180
52530
|
this.currentPath.shape.points.push(x, y);
|
52181
52531
|
this.dirty = true;
|
52532
|
+
this.updateLocalBounds();
|
52182
52533
|
|
52183
52534
|
return this;
|
52184
52535
|
};
|
@@ -52233,6 +52584,7 @@ PIXI.Graphics.prototype.quadraticCurveTo = function(cpX, cpY, toX, toY)
|
|
52233
52584
|
}
|
52234
52585
|
|
52235
52586
|
this.dirty = true;
|
52587
|
+
this.updateLocalBounds();
|
52236
52588
|
|
52237
52589
|
return this;
|
52238
52590
|
};
|
@@ -52291,6 +52643,7 @@ PIXI.Graphics.prototype.bezierCurveTo = function(cpX, cpY, cpX2, cpY2, toX, toY)
|
|
52291
52643
|
}
|
52292
52644
|
|
52293
52645
|
this.dirty = true;
|
52646
|
+
this.updateLocalBounds();
|
52294
52647
|
|
52295
52648
|
return this;
|
52296
52649
|
};
|
@@ -52360,6 +52713,7 @@ PIXI.Graphics.prototype.arcTo = function(x1, y1, x2, y2, radius)
|
|
52360
52713
|
}
|
52361
52714
|
|
52362
52715
|
this.dirty = true;
|
52716
|
+
this.updateLocalBounds();
|
52363
52717
|
|
52364
52718
|
return this;
|
52365
52719
|
};
|
@@ -52445,6 +52799,7 @@ PIXI.Graphics.prototype.arc = function(cx, cy, radius, startAngle, endAngle, ant
|
|
52445
52799
|
}
|
52446
52800
|
|
52447
52801
|
this.dirty = true;
|
52802
|
+
this.updateLocalBounds();
|
52448
52803
|
|
52449
52804
|
return this;
|
52450
52805
|
};
|
@@ -52606,6 +52961,8 @@ PIXI.Graphics.prototype.clear = function()
|
|
52606
52961
|
this.clearDirty = true;
|
52607
52962
|
this.graphicsData = [];
|
52608
52963
|
|
52964
|
+
this.updateLocalBounds();
|
52965
|
+
|
52609
52966
|
return this;
|
52610
52967
|
};
|
52611
52968
|
|
@@ -52640,8 +52997,6 @@ PIXI.Graphics.prototype.generateTexture = function(resolution, scaleMode, paddin
|
|
52640
52997
|
|
52641
52998
|
canvasBuffer.context.translate(-bounds.x, -bounds.y);
|
52642
52999
|
|
52643
|
-
// Call here
|
52644
|
-
|
52645
53000
|
PIXI.CanvasGraphics.renderGraphics(this, canvasBuffer.context);
|
52646
53001
|
|
52647
53002
|
return texture;
|
@@ -53153,8 +53508,11 @@ PIXI.Graphics.prototype.drawShape = function(shape)
|
|
53153
53508
|
}
|
53154
53509
|
|
53155
53510
|
this.dirty = true;
|
53511
|
+
|
53512
|
+
this.updateLocalBounds();
|
53156
53513
|
|
53157
53514
|
return data;
|
53515
|
+
|
53158
53516
|
};
|
53159
53517
|
|
53160
53518
|
/**
|
@@ -55340,7 +55698,29 @@ PIXI.CanvasGraphics.updateGraphicsTint = function(graphics)
|
|
55340
55698
|
*/
|
55341
55699
|
|
55342
55700
|
/**
|
55343
|
-
*
|
55701
|
+
* A Graphics object is a way to draw primitives to your game. Primitives include forms of geometry, such as Rectangles,
|
55702
|
+
* Circles and Polygons. They also include lines, arcs and curves. When you initially create a Graphics object it will
|
55703
|
+
* be empty. To 'draw' to it you first specify a lineStyle or fillStyle (or both), and then draw a shape. For example:
|
55704
|
+
*
|
55705
|
+
* ```
|
55706
|
+
* graphics.beginFill(0xff0000);
|
55707
|
+
* graphics.drawCircle(50, 50, 100);
|
55708
|
+
* graphics.endFill();
|
55709
|
+
* ```
|
55710
|
+
*
|
55711
|
+
* This will draw a circle shape to the Graphics object, with a diameter of 100, located at x: 50, y: 50.
|
55712
|
+
*
|
55713
|
+
* When a Graphics object is rendered it will render differently based on if the game is running under Canvas or
|
55714
|
+
* WebGL. Under Canvas it will use the HTML Canvas context drawing operations to draw the path. Under WebGL the
|
55715
|
+
* graphics data is decomposed into polygons. Both of these are expensive processes, especially with complex shapes.
|
55716
|
+
*
|
55717
|
+
* If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help
|
55718
|
+
* performance by calling `Graphics.generateTexture`. This will 'bake' the Graphics object into a Texture, and return it.
|
55719
|
+
* You can then use this Texture for Sprites or other display objects. If your Graphics object updates frequently then
|
55720
|
+
* you should avoid doing this, as it will constantly generate new textures, which will consume memory.
|
55721
|
+
*
|
55722
|
+
* As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful
|
55723
|
+
* in their complexity and quantity of them in your game.
|
55344
55724
|
*
|
55345
55725
|
* @class Phaser.Graphics
|
55346
55726
|
* @constructor
|
@@ -56955,18 +57335,34 @@ Phaser.Text.prototype.componentsToFont = function (components) {
|
|
56955
57335
|
};
|
56956
57336
|
|
56957
57337
|
/**
|
56958
|
-
|
56959
|
-
|
56960
|
-
|
56961
|
-
|
56962
|
-
|
56963
|
-
|
56964
|
-
|
56965
|
-
|
56966
|
-
|
57338
|
+
* The text to be displayed by this Text object.
|
57339
|
+
* Use a \n to insert a carriage return and split the text.
|
57340
|
+
* The text will be rendered with any style currently set.
|
57341
|
+
*
|
57342
|
+
* Use the optional `immediate` argument if you need the Text display to update immediately.
|
57343
|
+
*
|
57344
|
+
* If not it will re-create the texture of this Text object during the next time the render
|
57345
|
+
* loop is called.
|
57346
|
+
*
|
57347
|
+
* @method Phaser.Text#setText
|
57348
|
+
* @param {string} [text] - The text to be displayed. Set to an empty string to clear text that is already present.
|
57349
|
+
* @param {boolean} [immediate=false] - Update the texture used by this Text object immediately (true) or automatically during the next render loop (false).
|
57350
|
+
* @return {Phaser.Text} This Text instance.
|
57351
|
+
*/
|
57352
|
+
Phaser.Text.prototype.setText = function (text, immediate) {
|
57353
|
+
|
57354
|
+
if (immediate === undefined) { immediate = false; }
|
56967
57355
|
|
56968
57356
|
this.text = text.toString() || '';
|
56969
|
-
|
57357
|
+
|
57358
|
+
if (immediate)
|
57359
|
+
{
|
57360
|
+
this.updateText();
|
57361
|
+
}
|
57362
|
+
else
|
57363
|
+
{
|
57364
|
+
this.dirty = true;
|
57365
|
+
}
|
56970
57366
|
|
56971
57367
|
return this;
|
56972
57368
|
|
@@ -57977,7 +58373,7 @@ Object.defineProperty(Phaser.Text.prototype, 'height', {
|
|
57977
58373
|
|
57978
58374
|
Phaser.Text.fontPropertiesCache = {};
|
57979
58375
|
|
57980
|
-
Phaser.Text.fontPropertiesCanvas =
|
58376
|
+
Phaser.Text.fontPropertiesCanvas = document.createElement('canvas');
|
57981
58377
|
Phaser.Text.fontPropertiesContext = Phaser.Text.fontPropertiesCanvas.getContext('2d');
|
57982
58378
|
|
57983
58379
|
/**
|
@@ -59355,7 +59751,7 @@ Phaser.Rope = function (game, x, y, key, frame, points) {
|
|
59355
59751
|
*/
|
59356
59752
|
this.type = Phaser.ROPE;
|
59357
59753
|
|
59358
|
-
PIXI.Rope.call(this,
|
59754
|
+
PIXI.Rope.call(this, Phaser.Cache.DEFAULT, this.points);
|
59359
59755
|
|
59360
59756
|
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
|
59361
59757
|
|
@@ -61130,14 +61526,7 @@ Phaser.Canvas = {
|
|
61130
61526
|
width = width || 256;
|
61131
61527
|
height = height || 256;
|
61132
61528
|
|
61133
|
-
|
61134
|
-
{
|
61135
|
-
var canvas = PIXI.CanvasPool.create(parent, width, height);
|
61136
|
-
}
|
61137
|
-
else
|
61138
|
-
{
|
61139
|
-
var canvas = document.createElement('canvas');
|
61140
|
-
}
|
61529
|
+
var canvas = (skipPool) ? document.createElement('canvas') : PIXI.CanvasPool.create(parent, width, height);
|
61141
61530
|
|
61142
61531
|
if (typeof id === 'string' && id !== '')
|
61143
61532
|
{
|
@@ -61730,7 +62119,9 @@ Phaser.Math = {
|
|
61730
62119
|
* @return {number} n mod 1
|
61731
62120
|
*/
|
61732
62121
|
shear: function (n) {
|
62122
|
+
|
61733
62123
|
return n % 1;
|
62124
|
+
|
61734
62125
|
},
|
61735
62126
|
|
61736
62127
|
/**
|
@@ -61741,8 +62132,8 @@ Phaser.Math = {
|
|
61741
62132
|
* @method Phaser.Math#snapTo
|
61742
62133
|
* @param {number} input - The value to snap.
|
61743
62134
|
* @param {number} gap - The interval gap of the grid.
|
61744
|
-
* @param {number} [start] - Optional starting offset for gap.
|
61745
|
-
* @return {number}
|
62135
|
+
* @param {number} [start=0] - Optional starting offset for gap.
|
62136
|
+
* @return {number} The snapped value.
|
61746
62137
|
*/
|
61747
62138
|
snapTo: function (input, gap, start) {
|
61748
62139
|
|
@@ -61768,8 +62159,8 @@ Phaser.Math = {
|
|
61768
62159
|
* @method Phaser.Math#snapToFloor
|
61769
62160
|
* @param {number} input - The value to snap.
|
61770
62161
|
* @param {number} gap - The interval gap of the grid.
|
61771
|
-
* @param {number} [start] - Optional starting offset for gap.
|
61772
|
-
* @return {number}
|
62162
|
+
* @param {number} [start=0] - Optional starting offset for gap.
|
62163
|
+
* @return {number} The snapped value.
|
61773
62164
|
*/
|
61774
62165
|
snapToFloor: function (input, gap, start) {
|
61775
62166
|
|
@@ -61795,8 +62186,8 @@ Phaser.Math = {
|
|
61795
62186
|
* @method Phaser.Math#snapToCeil
|
61796
62187
|
* @param {number} input - The value to snap.
|
61797
62188
|
* @param {number} gap - The interval gap of the grid.
|
61798
|
-
* @param {number} [start] - Optional starting offset for gap.
|
61799
|
-
* @return {number}
|
62189
|
+
* @param {number} [start=0] - Optional starting offset for gap.
|
62190
|
+
* @return {number} The snapped value.
|
61800
62191
|
*/
|
61801
62192
|
snapToCeil: function (input, gap, start) {
|
61802
62193
|
|
@@ -61844,9 +62235,9 @@ Phaser.Math = {
|
|
61844
62235
|
*
|
61845
62236
|
* @method Phaser.Math#roundTo
|
61846
62237
|
* @param {number} value - The value to round.
|
61847
|
-
* @param {number} place - The place to round to.
|
61848
|
-
* @param {number} base - The base to round in
|
61849
|
-
* @return {number}
|
62238
|
+
* @param {number} [place=0] - The place to round to.
|
62239
|
+
* @param {number} [base=10] - The base to round in. Default is 10 for decimal.
|
62240
|
+
* @return {number} The rounded value.
|
61850
62241
|
*/
|
61851
62242
|
roundTo: function (value, place, base) {
|
61852
62243
|
|
@@ -61860,11 +62251,14 @@ Phaser.Math = {
|
|
61860
62251
|
},
|
61861
62252
|
|
61862
62253
|
/**
|
62254
|
+
* Floors to some place comparative to a `base`, default is 10 for decimal place.
|
62255
|
+
* The `place` is represented by the power applied to `base` to get that place.
|
62256
|
+
*
|
61863
62257
|
* @method Phaser.Math#floorTo
|
61864
62258
|
* @param {number} value - The value to round.
|
61865
|
-
* @param {number} place - The place to round to.
|
61866
|
-
* @param {number} base - The base to round in
|
61867
|
-
* @return {number}
|
62259
|
+
* @param {number} [place=0] - The place to round to.
|
62260
|
+
* @param {number} [base=10] - The base to round in. Default is 10 for decimal.
|
62261
|
+
* @return {number} The rounded value.
|
61868
62262
|
*/
|
61869
62263
|
floorTo: function (value, place, base) {
|
61870
62264
|
|
@@ -61878,11 +62272,14 @@ Phaser.Math = {
|
|
61878
62272
|
},
|
61879
62273
|
|
61880
62274
|
/**
|
62275
|
+
* Ceils to some place comparative to a `base`, default is 10 for decimal place.
|
62276
|
+
* The `place` is represented by the power applied to `base` to get that place.
|
62277
|
+
*
|
61881
62278
|
* @method Phaser.Math#ceilTo
|
61882
62279
|
* @param {number} value - The value to round.
|
61883
|
-
* @param {number} place - The place to round to.
|
61884
|
-
* @param {number} base - The base to round in
|
61885
|
-
* @return {number}
|
62280
|
+
* @param {number} [place=0] - The place to round to.
|
62281
|
+
* @param {number} [base=10] - The base to round in. Default is 10 for decimal.
|
62282
|
+
* @return {number} The rounded value.
|
61886
62283
|
*/
|
61887
62284
|
ceilTo: function (value, place, base) {
|
61888
62285
|
|
@@ -61897,42 +62294,51 @@ Phaser.Math = {
|
|
61897
62294
|
|
61898
62295
|
/**
|
61899
62296
|
* Find the angle of a segment from (x1, y1) -> (x2, y2).
|
62297
|
+
*
|
61900
62298
|
* @method Phaser.Math#angleBetween
|
61901
|
-
* @param {number} x1
|
61902
|
-
* @param {number} y1
|
61903
|
-
* @param {number} x2
|
61904
|
-
* @param {number} y2
|
62299
|
+
* @param {number} x1 - The x coordinate of the first value.
|
62300
|
+
* @param {number} y1 - The y coordinate of the first value.
|
62301
|
+
* @param {number} x2 - The x coordinate of the second value.
|
62302
|
+
* @param {number} y2 - The y coordinate of the second value.
|
61905
62303
|
* @return {number} The angle, in radians.
|
61906
62304
|
*/
|
61907
62305
|
angleBetween: function (x1, y1, x2, y2) {
|
62306
|
+
|
61908
62307
|
return Math.atan2(y2 - y1, x2 - x1);
|
62308
|
+
|
61909
62309
|
},
|
61910
62310
|
|
61911
62311
|
/**
|
61912
62312
|
* Find the angle of a segment from (x1, y1) -> (x2, y2).
|
61913
|
-
*
|
62313
|
+
*
|
62314
|
+
* The difference between this method and Math.angleBetween is that this assumes the y coordinate travels
|
61914
62315
|
* down the screen.
|
61915
62316
|
*
|
61916
62317
|
* @method Phaser.Math#angleBetweenY
|
61917
|
-
* @param {number} x1
|
61918
|
-
* @param {number} y1
|
61919
|
-
* @param {number} x2
|
61920
|
-
* @param {number} y2
|
62318
|
+
* @param {number} x1 - The x coordinate of the first value.
|
62319
|
+
* @param {number} y1 - The y coordinate of the first value.
|
62320
|
+
* @param {number} x2 - The x coordinate of the second value.
|
62321
|
+
* @param {number} y2 - The y coordinate of the second value.
|
61921
62322
|
* @return {number} The angle, in radians.
|
61922
62323
|
*/
|
61923
62324
|
angleBetweenY: function (x1, y1, x2, y2) {
|
62325
|
+
|
61924
62326
|
return Math.atan2(x2 - x1, y2 - y1);
|
62327
|
+
|
61925
62328
|
},
|
61926
62329
|
|
61927
62330
|
/**
|
61928
62331
|
* Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
|
62332
|
+
*
|
61929
62333
|
* @method Phaser.Math#angleBetweenPoints
|
61930
|
-
* @param {Phaser.Point} point1
|
61931
|
-
* @param {Phaser.Point} point2
|
61932
|
-
* @return {number} The angle, in radians.
|
62334
|
+
* @param {Phaser.Point} point1 - The first point.
|
62335
|
+
* @param {Phaser.Point} point2 - The second point.
|
62336
|
+
* @return {number} The angle between the two points, in radians.
|
61933
62337
|
*/
|
61934
62338
|
angleBetweenPoints: function (point1, point2) {
|
62339
|
+
|
61935
62340
|
return Math.atan2(point2.y - point1.y, point2.x - point1.x);
|
62341
|
+
|
61936
62342
|
},
|
61937
62343
|
|
61938
62344
|
/**
|
@@ -61943,24 +62349,28 @@ Phaser.Math = {
|
|
61943
62349
|
* @return {number} The angle, in radians.
|
61944
62350
|
*/
|
61945
62351
|
angleBetweenPointsY: function (point1, point2) {
|
62352
|
+
|
61946
62353
|
return Math.atan2(point2.x - point1.x, point2.y - point1.y);
|
62354
|
+
|
61947
62355
|
},
|
61948
62356
|
|
61949
62357
|
/**
|
61950
62358
|
* Reverses an angle.
|
61951
62359
|
* @method Phaser.Math#reverseAngle
|
61952
62360
|
* @param {number} angleRad - The angle to reverse, in radians.
|
61953
|
-
* @return {number}
|
62361
|
+
* @return {number} The reverse angle, in radians.
|
61954
62362
|
*/
|
61955
62363
|
reverseAngle: function (angleRad) {
|
62364
|
+
|
61956
62365
|
return this.normalizeAngle(angleRad + Math.PI, true);
|
62366
|
+
|
61957
62367
|
},
|
61958
62368
|
|
61959
62369
|
/**
|
61960
62370
|
* Normalizes an angle to the [0,2pi) range.
|
61961
62371
|
* @method Phaser.Math#normalizeAngle
|
61962
62372
|
* @param {number} angleRad - The angle to normalize, in radians.
|
61963
|
-
* @return {number}
|
62373
|
+
* @return {number} The angle, fit within the [0,2pi] range, in radians.
|
61964
62374
|
*/
|
61965
62375
|
normalizeAngle: function (angleRad) {
|
61966
62376
|
|
@@ -61976,10 +62386,12 @@ Phaser.Math = {
|
|
61976
62386
|
* @param {number} value - The value to add the amount to.
|
61977
62387
|
* @param {number} amount - The amount to add to the value.
|
61978
62388
|
* @param {number} max - The maximum the value is allowed to be.
|
61979
|
-
* @return {number}
|
62389
|
+
* @return {number} The new value.
|
61980
62390
|
*/
|
61981
62391
|
maxAdd: function (value, amount, max) {
|
62392
|
+
|
61982
62393
|
return Math.min(value + amount, max);
|
62394
|
+
|
61983
62395
|
},
|
61984
62396
|
|
61985
62397
|
/**
|
@@ -61992,7 +62404,9 @@ Phaser.Math = {
|
|
61992
62404
|
* @return {number} The new value.
|
61993
62405
|
*/
|
61994
62406
|
minSub: function (value, amount, min) {
|
62407
|
+
|
61995
62408
|
return Math.max(value - amount, min);
|
62409
|
+
|
61996
62410
|
},
|
61997
62411
|
|
61998
62412
|
/**
|
@@ -62057,8 +62471,10 @@ Phaser.Math = {
|
|
62057
62471
|
* @return {boolean} True if the given number is odd. False if the given number is even.
|
62058
62472
|
*/
|
62059
62473
|
isOdd: function (n) {
|
62474
|
+
|
62060
62475
|
// Does not work with extremely large values
|
62061
62476
|
return !!(n & 1);
|
62477
|
+
|
62062
62478
|
},
|
62063
62479
|
|
62064
62480
|
/**
|
@@ -62069,8 +62485,10 @@ Phaser.Math = {
|
|
62069
62485
|
* @return {boolean} True if the given number is even. False if the given number is odd.
|
62070
62486
|
*/
|
62071
62487
|
isEven: function (n) {
|
62488
|
+
|
62072
62489
|
// Does not work with extremely large values
|
62073
62490
|
return !(n & 1);
|
62491
|
+
|
62074
62492
|
},
|
62075
62493
|
|
62076
62494
|
/**
|
@@ -62307,11 +62725,13 @@ Phaser.Math = {
|
|
62307
62725
|
* @method Phaser.Math#linear
|
62308
62726
|
* @param {number} p0
|
62309
62727
|
* @param {number} p1
|
62310
|
-
* @param {number} t
|
62728
|
+
* @param {number} t - A value between 0 and 1.
|
62311
62729
|
* @return {number}
|
62312
62730
|
*/
|
62313
62731
|
linear: function (p0, p1, t) {
|
62732
|
+
|
62314
62733
|
return (p1 - p0) * t + p0;
|
62734
|
+
|
62315
62735
|
},
|
62316
62736
|
|
62317
62737
|
/**
|
@@ -62322,7 +62742,9 @@ Phaser.Math = {
|
|
62322
62742
|
* @return {number}
|
62323
62743
|
*/
|
62324
62744
|
bernstein: function (n, i) {
|
62745
|
+
|
62325
62746
|
return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
|
62747
|
+
|
62326
62748
|
},
|
62327
62749
|
|
62328
62750
|
/**
|
@@ -62330,7 +62752,7 @@ Phaser.Math = {
|
|
62330
62752
|
* @param {number} value - the number you want to evaluate
|
62331
62753
|
* @return {number}
|
62332
62754
|
*/
|
62333
|
-
factorial
|
62755
|
+
factorial: function (value) {
|
62334
62756
|
|
62335
62757
|
if (value === 0)
|
62336
62758
|
{
|
@@ -62369,15 +62791,17 @@ Phaser.Math = {
|
|
62369
62791
|
},
|
62370
62792
|
|
62371
62793
|
/**
|
62372
|
-
* The
|
62794
|
+
* The absolute difference between two values.
|
62373
62795
|
*
|
62374
62796
|
* @method Phaser.Math#difference
|
62375
|
-
* @param {number} a
|
62376
|
-
* @param {number} b
|
62377
|
-
* @return {number}
|
62797
|
+
* @param {number} a - The first value to check.
|
62798
|
+
* @param {number} b - The second value to check.
|
62799
|
+
* @return {number} The absolute difference between the two values.
|
62378
62800
|
*/
|
62379
62801
|
difference: function (a, b) {
|
62802
|
+
|
62380
62803
|
return Math.abs(a - b);
|
62804
|
+
|
62381
62805
|
},
|
62382
62806
|
|
62383
62807
|
/**
|
@@ -62528,7 +62952,9 @@ Phaser.Math = {
|
|
62528
62952
|
* @return {number}
|
62529
62953
|
*/
|
62530
62954
|
clampBottom: function (x, a) {
|
62955
|
+
|
62531
62956
|
return x < a ? a : x;
|
62957
|
+
|
62532
62958
|
},
|
62533
62959
|
|
62534
62960
|
/**
|
@@ -62542,22 +62968,26 @@ Phaser.Math = {
|
|
62542
62968
|
* @see {@link Phaser.Math.fuzzyEqual}
|
62543
62969
|
*/
|
62544
62970
|
within: function (a, b, tolerance) {
|
62971
|
+
|
62545
62972
|
return (Math.abs(a - b) <= tolerance);
|
62973
|
+
|
62546
62974
|
},
|
62547
62975
|
|
62548
62976
|
/**
|
62549
62977
|
* Linear mapping from range <a1, a2> to range <b1, b2>
|
62550
62978
|
*
|
62551
62979
|
* @method Phaser.Math#mapLinear
|
62552
|
-
* @param {number} x
|
62553
|
-
* @param {number} a1
|
62554
|
-
* @param {number} a2
|
62555
|
-
* @param {number} b1
|
62556
|
-
* @param {number} b2
|
62980
|
+
* @param {number} x - The value to map
|
62981
|
+
* @param {number} a1 - First endpoint of the range <a1, a2>
|
62982
|
+
* @param {number} a2 - Final endpoint of the range <a1, a2>
|
62983
|
+
* @param {number} b1 - First endpoint of the range <b1, b2>
|
62984
|
+
* @param {number} b2 - Final endpoint of the range <b1, b2>
|
62557
62985
|
* @return {number}
|
62558
62986
|
*/
|
62559
62987
|
mapLinear: function (x, a1, a2, b1, b2) {
|
62988
|
+
|
62560
62989
|
return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
|
62990
|
+
|
62561
62991
|
},
|
62562
62992
|
|
62563
62993
|
/**
|
@@ -62589,8 +63019,11 @@ Phaser.Math = {
|
|
62589
63019
|
* @return {float} A value between 0 and 1.
|
62590
63020
|
*/
|
62591
63021
|
smootherstep: function (x, min, max) {
|
63022
|
+
|
62592
63023
|
x = Math.max(0, Math.min(1, (x - min) / (max - min)));
|
63024
|
+
|
62593
63025
|
return x * x * x * (x * (x * 6 - 15) + 10);
|
63026
|
+
|
62594
63027
|
},
|
62595
63028
|
|
62596
63029
|
/**
|
@@ -62603,7 +63036,9 @@ Phaser.Math = {
|
|
62603
63036
|
* @return {integer} An integer in {-1, 0, 1}
|
62604
63037
|
*/
|
62605
63038
|
sign: function (x) {
|
63039
|
+
|
62606
63040
|
return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 );
|
63041
|
+
|
62607
63042
|
},
|
62608
63043
|
|
62609
63044
|
/**
|
@@ -67840,7 +68275,7 @@ Phaser.AnimationManager.prototype = {
|
|
67840
68275
|
refreshFrame: function () {
|
67841
68276
|
|
67842
68277
|
// TODO
|
67843
|
-
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
68278
|
+
// this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
67844
68279
|
|
67845
68280
|
},
|
67846
68281
|
|
@@ -68315,7 +68750,7 @@ Phaser.Animation.prototype = {
|
|
68315
68750
|
{
|
68316
68751
|
for (var i = 0; i < this._frames.length; i++)
|
68317
68752
|
{
|
68318
|
-
if (this._frames[i] ===
|
68753
|
+
if (this._frames[i] === frameId)
|
68319
68754
|
{
|
68320
68755
|
frameIndex = i;
|
68321
68756
|
}
|
@@ -69937,6 +70372,20 @@ Phaser.Cache.SHADER = 14;
|
|
69937
70372
|
*/
|
69938
70373
|
Phaser.Cache.RENDER_TEXTURE = 15;
|
69939
70374
|
|
70375
|
+
/**
|
70376
|
+
* The default image used for a texture when no other is specified.
|
70377
|
+
* @constant
|
70378
|
+
* @type {PIXI.Texture}
|
70379
|
+
*/
|
70380
|
+
Phaser.Cache.DEFAULT = null;
|
70381
|
+
|
70382
|
+
/**
|
70383
|
+
* The default image used for a texture when the source image is missing.
|
70384
|
+
* @constant
|
70385
|
+
* @type {PIXI.Texture}
|
70386
|
+
*/
|
70387
|
+
Phaser.Cache.MISSING = null;
|
70388
|
+
|
69940
70389
|
Phaser.Cache.prototype = {
|
69941
70390
|
|
69942
70391
|
//////////////////
|
@@ -69991,6 +70440,15 @@ Phaser.Cache.prototype = {
|
|
69991
70440
|
|
69992
70441
|
this._resolveURL(url, img);
|
69993
70442
|
|
70443
|
+
if (key === '__default')
|
70444
|
+
{
|
70445
|
+
Phaser.Cache.DEFAULT = new PIXI.Texture(img.base);
|
70446
|
+
}
|
70447
|
+
else if (key === '__missing')
|
70448
|
+
{
|
70449
|
+
Phaser.Cache.MISSING = new PIXI.Texture(img.base);
|
70450
|
+
}
|
70451
|
+
|
69994
70452
|
return img;
|
69995
70453
|
|
69996
70454
|
},
|
@@ -70015,7 +70473,8 @@ Phaser.Cache.prototype = {
|
|
70015
70473
|
// Because we don't want to invalidate the sprite batch for an invisible texture
|
70016
70474
|
obj.base.skipRender = true;
|
70017
70475
|
|
70018
|
-
|
70476
|
+
// Make it easily available within the rest of Phaser / Pixi
|
70477
|
+
Phaser.Cache.DEFAULT = new PIXI.Texture(obj.base);
|
70019
70478
|
|
70020
70479
|
},
|
70021
70480
|
|
@@ -70036,7 +70495,8 @@ Phaser.Cache.prototype = {
|
|
70036
70495
|
|
70037
70496
|
var obj = this.addImage('__missing', null, img);
|
70038
70497
|
|
70039
|
-
|
70498
|
+
// Make it easily available within the rest of Phaser / Pixi
|
70499
|
+
Phaser.Cache.MISSING = new PIXI.Texture(obj.base);
|
70040
70500
|
|
70041
70501
|
},
|
70042
70502
|
|
@@ -71286,71 +71746,6 @@ Phaser.Cache.prototype = {
|
|
71286
71746
|
|
71287
71747
|
},
|
71288
71748
|
|
71289
|
-
/**
|
71290
|
-
* Gets a PIXI.Texture by key from the PIXI.TextureCache.
|
71291
|
-
*
|
71292
|
-
* If the texture isn't found in the cache, then it searches the Phaser Image Cache and
|
71293
|
-
* creates a new PIXI.Texture object which is then returned.
|
71294
|
-
*
|
71295
|
-
* @method Phaser.Cache#getPixiTexture
|
71296
|
-
* @deprecated
|
71297
|
-
* @param {string} key - Asset key of the Texture to retrieve from the Cache.
|
71298
|
-
* @return {PIXI.Texture} The Texture object.
|
71299
|
-
*/
|
71300
|
-
getPixiTexture: function (key) {
|
71301
|
-
|
71302
|
-
if (PIXI.TextureCache[key])
|
71303
|
-
{
|
71304
|
-
return PIXI.TextureCache[key];
|
71305
|
-
}
|
71306
|
-
else
|
71307
|
-
{
|
71308
|
-
var base = this.getPixiBaseTexture(key);
|
71309
|
-
|
71310
|
-
if (base)
|
71311
|
-
{
|
71312
|
-
return new PIXI.Texture(base);
|
71313
|
-
}
|
71314
|
-
else
|
71315
|
-
{
|
71316
|
-
return null;
|
71317
|
-
}
|
71318
|
-
}
|
71319
|
-
|
71320
|
-
},
|
71321
|
-
|
71322
|
-
/**
|
71323
|
-
* Gets a PIXI.BaseTexture by key from the PIXI.BaseTextureCache.
|
71324
|
-
*
|
71325
|
-
* If the texture isn't found in the cache, then it searches the Phaser Image Cache.
|
71326
|
-
*
|
71327
|
-
* @method Phaser.Cache#getPixiBaseTexture
|
71328
|
-
* @deprecated
|
71329
|
-
* @param {string} key - Asset key of the BaseTexture to retrieve from the Cache.
|
71330
|
-
* @return {PIXI.BaseTexture} The BaseTexture object or null if not found.
|
71331
|
-
*/
|
71332
|
-
getPixiBaseTexture: function (key) {
|
71333
|
-
|
71334
|
-
if (PIXI.BaseTextureCache[key])
|
71335
|
-
{
|
71336
|
-
return PIXI.BaseTextureCache[key];
|
71337
|
-
}
|
71338
|
-
else
|
71339
|
-
{
|
71340
|
-
var img = this.getItem(key, Phaser.Cache.IMAGE, 'getPixiBaseTexture');
|
71341
|
-
|
71342
|
-
if (img !== null)
|
71343
|
-
{
|
71344
|
-
return img.base;
|
71345
|
-
}
|
71346
|
-
else
|
71347
|
-
{
|
71348
|
-
return null;
|
71349
|
-
}
|
71350
|
-
}
|
71351
|
-
|
71352
|
-
},
|
71353
|
-
|
71354
71749
|
/**
|
71355
71750
|
* Get a cached object by the URL.
|
71356
71751
|
* This only returns a value if you set Cache.autoResolveURL to `true` *before* starting the preload of any assets.
|
@@ -71428,20 +71823,20 @@ Phaser.Cache.prototype = {
|
|
71428
71823
|
*
|
71429
71824
|
* You can optionally elect to destroy it as well. This calls BaseTexture.destroy on it.
|
71430
71825
|
*
|
71431
|
-
* Note that this only removes it from the Phaser
|
71826
|
+
* Note that this only removes it from the Phaser Cache. If you still have references to the data elsewhere
|
71432
71827
|
* then it will persist in memory.
|
71433
71828
|
*
|
71434
71829
|
* @method Phaser.Cache#removeImage
|
71435
71830
|
* @param {string} key - Key of the asset you want to remove.
|
71436
|
-
* @param {boolean} [
|
71831
|
+
* @param {boolean} [destroyBaseTexture=true] - Should the BaseTexture behind this image also be destroyed?
|
71437
71832
|
*/
|
71438
|
-
removeImage: function (key,
|
71833
|
+
removeImage: function (key, destroyBaseTexture) {
|
71439
71834
|
|
71440
|
-
if (
|
71835
|
+
if (destroyBaseTexture === undefined) { destroyBaseTexture = true; }
|
71441
71836
|
|
71442
71837
|
var img = this.getImage(key, true);
|
71443
71838
|
|
71444
|
-
if (
|
71839
|
+
if (destroyBaseTexture && img.base)
|
71445
71840
|
{
|
71446
71841
|
img.base.destroy();
|
71447
71842
|
}
|
@@ -71855,7 +72250,19 @@ Phaser.Loader = function (game) {
|
|
71855
72250
|
this.path = '';
|
71856
72251
|
|
71857
72252
|
/**
|
71858
|
-
*
|
72253
|
+
* Used to map the application mime-types to to the Accept header in XHR requests.
|
72254
|
+
* If you don't require these mappings, or they cause problems on your server, then
|
72255
|
+
* remove them from the headers object and the XHR request will not try to use them.
|
72256
|
+
* @property {object} headers
|
72257
|
+
* @default
|
72258
|
+
*/
|
72259
|
+
this.headers = {
|
72260
|
+
json: "application/json",
|
72261
|
+
xml: "application/xml"
|
72262
|
+
};
|
72263
|
+
|
72264
|
+
/**
|
72265
|
+
* This event is dispatched when the loading process starts: before the first file has been requested,
|
71859
72266
|
* but after all the initial packs have been loaded.
|
71860
72267
|
*
|
71861
72268
|
* @property {Phaser.Signal} onLoadStart
|
@@ -74070,6 +74477,11 @@ Phaser.Loader.prototype = {
|
|
74070
74477
|
xhr.open("GET", url, true);
|
74071
74478
|
xhr.responseType = type;
|
74072
74479
|
|
74480
|
+
if (this.headers[file.type])
|
74481
|
+
{
|
74482
|
+
xhr.setRequestHeader("Accept", this.headers[file.type]);
|
74483
|
+
}
|
74484
|
+
|
74073
74485
|
onerror = onerror || this.fileError;
|
74074
74486
|
|
74075
74487
|
var _this = this;
|
@@ -75130,11 +75542,6 @@ Phaser.Sound = function (game, key, volume, loop, connect) {
|
|
75130
75542
|
*/
|
75131
75543
|
this.loop = loop;
|
75132
75544
|
|
75133
|
-
/**
|
75134
|
-
* @property {number} volume - The sound or sound marker volume. A value between 0 (silence) and 1 (full volume).
|
75135
|
-
*/
|
75136
|
-
this.volume = volume;
|
75137
|
-
|
75138
75545
|
/**
|
75139
75546
|
* @property {object} markers - The sound markers.
|
75140
75547
|
*/
|
@@ -75639,7 +76046,7 @@ Phaser.Sound.prototype = {
|
|
75639
76046
|
{
|
75640
76047
|
this._sound.disconnect(this.externalNode);
|
75641
76048
|
}
|
75642
|
-
else
|
76049
|
+
else if (this.gainNode)
|
75643
76050
|
{
|
75644
76051
|
this._sound.disconnect(this.gainNode);
|
75645
76052
|
}
|
@@ -75977,7 +76384,7 @@ Phaser.Sound.prototype = {
|
|
75977
76384
|
{
|
75978
76385
|
this._sound.disconnect(this.externalNode);
|
75979
76386
|
}
|
75980
|
-
else
|
76387
|
+
else if (this.gainNode)
|
75981
76388
|
{
|
75982
76389
|
this._sound.disconnect(this.gainNode);
|
75983
76390
|
}
|
@@ -79522,10 +79929,15 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "isGameLandscape", {
|
|
79522
79929
|
|
79523
79930
|
/**
|
79524
79931
|
* A collection of methods for displaying debug information about game objects.
|
79932
|
+
*
|
79933
|
+
* If your game is running in Canvas mode, then you should invoke all of the Debug methods from
|
79934
|
+
* your games `render` function. This is because they are drawn directly onto the game canvas
|
79935
|
+
* itself, so if you call any debug methods outside of `render` they are likely to be overwritten
|
79936
|
+
* by the game itself.
|
79937
|
+
*
|
79525
79938
|
* If your game is running in WebGL then Debug will create a Sprite that is placed at the top of the Stage display list and bind a canvas texture
|
79526
79939
|
* to it, which must be uploaded every frame. Be advised: this is very expensive, especially in browsers like Firefox. So please only enable Debug
|
79527
79940
|
* in WebGL mode if you really need it (or your desktop can cope with it well) and disable it for production!
|
79528
|
-
* If your game is using a Canvas renderer then the debug information is literally drawn on the top of the active game canvas and no Sprite is used.
|
79529
79941
|
*
|
79530
79942
|
* @class Phaser.Utils.Debug
|
79531
79943
|
* @constructor
|
@@ -79620,7 +80032,7 @@ Phaser.Utils.Debug.prototype = {
|
|
79620
80032
|
}
|
79621
80033
|
else
|
79622
80034
|
{
|
79623
|
-
this.bmd = this.game
|
80035
|
+
this.bmd = new Phaser.BitmapData(this.game, '__DEBUG', this.game.width, this.game.height, true);
|
79624
80036
|
this.sprite = this.game.make.image(0, 0, this.bmd);
|
79625
80037
|
this.game.stage.addChild(this.sprite);
|
79626
80038
|
|
@@ -81309,13 +81721,63 @@ Phaser.ArrayUtils = {
|
|
81309
81721
|
|
81310
81722
|
},
|
81311
81723
|
|
81724
|
+
/**
|
81725
|
+
* Moves the element from the end of the array to the start, shifting all items in the process.
|
81726
|
+
* The "rotation" happens to the right.
|
81727
|
+
*
|
81728
|
+
* Before: `[ A, B, C, D, E, F ]`
|
81729
|
+
* After: `[ F, A, B, C, D, E ]`
|
81730
|
+
*
|
81731
|
+
* See also Phaser.ArrayUtils.rotateLeft.
|
81732
|
+
*
|
81733
|
+
* @method Phaser.ArrayUtils.rotateRight
|
81734
|
+
* @param {any[]} array - The array to rotate. The array is modified.
|
81735
|
+
* @return {any} The shifted value.
|
81736
|
+
*/
|
81737
|
+
rotateRight: function (array) {
|
81738
|
+
|
81739
|
+
var s = array.pop();
|
81740
|
+
array.unshift(s);
|
81741
|
+
|
81742
|
+
return s;
|
81743
|
+
|
81744
|
+
},
|
81745
|
+
|
81746
|
+
/**
|
81747
|
+
* Moves the element from the start of the array to the end, shifting all items in the process.
|
81748
|
+
* The "rotation" happens to the left.
|
81749
|
+
*
|
81750
|
+
* Before: `[ A, B, C, D, E, F ]`
|
81751
|
+
* After: `[ B, C, D, E, F, A ]`
|
81752
|
+
*
|
81753
|
+
* See also Phaser.ArrayUtils.rotateRight
|
81754
|
+
*
|
81755
|
+
* @method Phaser.ArrayUtils.rotateLeft
|
81756
|
+
* @param {any[]} array - The array to rotate. The array is modified.
|
81757
|
+
* @return {any} The rotated value.
|
81758
|
+
*/
|
81759
|
+
rotateLeft: function (array) {
|
81760
|
+
|
81761
|
+
var s = array.shift();
|
81762
|
+
array.push(s);
|
81763
|
+
|
81764
|
+
return s;
|
81765
|
+
|
81766
|
+
},
|
81767
|
+
|
81312
81768
|
/**
|
81313
81769
|
* Moves the element from the start of the array to the end, shifting all items in the process.
|
81314
81770
|
* The "rotation" happens to the left.
|
81315
81771
|
*
|
81772
|
+
* Before: `[ A, B, C, D, E, F ]`
|
81773
|
+
* After: `[ B, C, D, E, F, A ]`
|
81774
|
+
*
|
81775
|
+
* See also Phaser.ArrayUtils.rotateRight
|
81776
|
+
*
|
81316
81777
|
* @method Phaser.ArrayUtils.rotate
|
81317
|
-
* @
|
81318
|
-
* @
|
81778
|
+
* @deprecated Please use Phaser.ArrayUtils.rotate instead.
|
81779
|
+
* @param {any[]} array - The array to rotate. The array is modified.
|
81780
|
+
* @return {any} The rotated value.
|
81319
81781
|
*/
|
81320
81782
|
rotate: function (array) {
|
81321
81783
|
|
@@ -82389,6 +82851,23 @@ Phaser.Color = {
|
|
82389
82851
|
|
82390
82852
|
},
|
82391
82853
|
|
82854
|
+
/**
|
82855
|
+
* Converts RGBA components to a 32 bit integer in AABBGGRR format.
|
82856
|
+
*
|
82857
|
+
* @method Phaser.Color.toABGR
|
82858
|
+
* @static
|
82859
|
+
* @param {number} r - The red color component, in the range 0 - 255.
|
82860
|
+
* @param {number} g - The green color component, in the range 0 - 255.
|
82861
|
+
* @param {number} b - The blue color component, in the range 0 - 255.
|
82862
|
+
* @param {number} a - The alpha color component, in the range 0 - 255.
|
82863
|
+
* @return {number} A RGBA-packed 32 bit integer
|
82864
|
+
*/
|
82865
|
+
toABGR: function (r, g, b, a) {
|
82866
|
+
|
82867
|
+
return ((a << 24) | (b << 16) | (g << 8) | r) >>> 0;
|
82868
|
+
|
82869
|
+
},
|
82870
|
+
|
82392
82871
|
/**
|
82393
82872
|
* Converts an RGB color value to HSL (hue, saturation and lightness).
|
82394
82873
|
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
|
@@ -84724,67 +85203,70 @@ Phaser.Physics.Arcade.prototype = {
|
|
84724
85203
|
return;
|
84725
85204
|
}
|
84726
85205
|
|
84727
|
-
var body;
|
84728
|
-
|
84729
85206
|
if (this.skipQuadTree || sprite.body.skipQuadTree)
|
84730
85207
|
{
|
85208
|
+
var bounds;
|
85209
|
+
|
84731
85210
|
for (var i = 0; i < group.hash.length; i++)
|
84732
85211
|
{
|
85212
|
+
var object1 = group.hash[i];
|
85213
|
+
|
84733
85214
|
// Skip duff entries - we can't check a non-existent sprite or one with no body
|
84734
|
-
if (!
|
85215
|
+
if (!object1 || !object1.exists || !object1.body)
|
84735
85216
|
{
|
84736
85217
|
continue;
|
84737
85218
|
}
|
84738
85219
|
|
84739
|
-
|
85220
|
+
// Inject the Body bounds data into the bounds object
|
85221
|
+
bounds = object1.body.getBounds(bounds);
|
84740
85222
|
|
84741
85223
|
// Skip items either side of the sprite
|
84742
85224
|
if (this.sortDirection === Phaser.Physics.Arcade.LEFT_RIGHT)
|
84743
85225
|
{
|
84744
|
-
if (sprite.body.right <
|
85226
|
+
if (sprite.body.right < bounds.x)
|
84745
85227
|
{
|
84746
85228
|
break;
|
84747
85229
|
}
|
84748
|
-
else if (
|
85230
|
+
else if (bounds.right < sprite.body.x)
|
84749
85231
|
{
|
84750
85232
|
continue;
|
84751
85233
|
}
|
84752
85234
|
}
|
84753
85235
|
else if (this.sortDirection === Phaser.Physics.Arcade.RIGHT_LEFT)
|
84754
85236
|
{
|
84755
|
-
if (sprite.body.x >
|
85237
|
+
if (sprite.body.x > bounds.right)
|
84756
85238
|
{
|
84757
85239
|
break;
|
84758
85240
|
}
|
84759
|
-
else if (
|
85241
|
+
else if (bounds.x > sprite.body.right)
|
84760
85242
|
{
|
84761
85243
|
continue;
|
84762
85244
|
}
|
84763
85245
|
}
|
84764
85246
|
else if (this.sortDirection === Phaser.Physics.Arcade.TOP_BOTTOM)
|
84765
85247
|
{
|
84766
|
-
if (sprite.body.bottom <
|
85248
|
+
if (sprite.body.bottom < bounds.y)
|
84767
85249
|
{
|
84768
85250
|
break;
|
84769
85251
|
}
|
84770
|
-
else if (
|
85252
|
+
else if (bounds.bottom < sprite.body.y)
|
84771
85253
|
{
|
84772
85254
|
continue;
|
84773
85255
|
}
|
84774
85256
|
}
|
84775
85257
|
else if (this.sortDirection === Phaser.Physics.Arcade.BOTTOM_TOP)
|
84776
85258
|
{
|
84777
|
-
if (sprite.body.y >
|
85259
|
+
if (sprite.body.y > bounds.bottom)
|
84778
85260
|
{
|
84779
85261
|
break;
|
84780
85262
|
}
|
84781
|
-
else if (
|
85263
|
+
else if (bounds.y > sprite.body.bottom)
|
84782
85264
|
{
|
84783
85265
|
continue;
|
84784
85266
|
}
|
84785
85267
|
}
|
84786
85268
|
|
84787
|
-
this.collideSpriteVsSprite(sprite,
|
85269
|
+
this.collideSpriteVsSprite(sprite, object1, collideCallback, processCallback, callbackContext, overlapOnly);
|
84788
85270
|
}
|
84789
85271
|
}
|
84790
85272
|
else
|
@@ -84836,65 +85318,73 @@ Phaser.Physics.Arcade.prototype = {
|
|
84836
85318
|
|
84837
85319
|
for (var i = 0; i < group.hash.length; i++)
|
84838
85320
|
{
|
85321
|
+
var bounds1;
|
85322
|
+
var object1 = group.hash[i];
|
85323
|
+
|
84839
85324
|
// Skip duff entries - we can't check a non-existent sprite or one with no body
|
84840
|
-
if (!
|
85325
|
+
if (!object1 || !object1.exists || !object1.body)
|
84841
85326
|
{
|
84842
85327
|
continue;
|
84843
85328
|
}
|
84844
85329
|
|
84845
|
-
|
85330
|
+
// Inject the Body bounds data into the bounds1 object
|
85331
|
+
bounds1 = object1.body.getBounds(bounds1);
|
84846
85332
|
|
84847
85333
|
for (var j = i + 1; j < group.hash.length; j++)
|
84848
85334
|
{
|
85335
|
+
var bounds2;
|
85336
|
+
var object2 = group.hash[j];
|
85337
|
+
|
84849
85338
|
// Skip duff entries - we can't check a non-existent sprite or one with no body
|
84850
|
-
if (!
|
85339
|
+
if (!object2 || !object2.exists || !object2.body)
|
84851
85340
|
{
|
84852
85341
|
continue;
|
84853
85342
|
}
|
84854
85343
|
|
84855
|
-
|
85344
|
+
// Inject the Body bounds data into the bounds2 object
|
85345
|
+
bounds2 = object2.body.getBounds(bounds2);
|
84856
85346
|
|
84857
85347
|
// Skip items either side of the sprite
|
84858
85348
|
if (this.sortDirection === Phaser.Physics.Arcade.LEFT_RIGHT)
|
84859
85349
|
{
|
84860
|
-
if (
|
85350
|
+
if (bounds1.right < bounds2.x)
|
84861
85351
|
{
|
84862
85352
|
break;
|
84863
85353
|
}
|
84864
|
-
else if (
|
85354
|
+
else if (bounds2.right < bounds1.x)
|
84865
85355
|
{
|
84866
85356
|
continue;
|
84867
85357
|
}
|
84868
85358
|
}
|
84869
85359
|
else if (this.sortDirection === Phaser.Physics.Arcade.RIGHT_LEFT)
|
84870
85360
|
{
|
84871
|
-
if (
|
85361
|
+
if (bounds1.x > bounds2.right)
|
84872
85362
|
{
|
84873
85363
|
continue;
|
84874
85364
|
}
|
84875
|
-
else if (
|
85365
|
+
else if (bounds2.x > bounds1.right)
|
84876
85366
|
{
|
84877
85367
|
break;
|
84878
85368
|
}
|
84879
85369
|
}
|
84880
85370
|
else if (this.sortDirection === Phaser.Physics.Arcade.TOP_BOTTOM)
|
84881
85371
|
{
|
84882
|
-
if (
|
85372
|
+
if (bounds1.bottom < bounds2.y)
|
84883
85373
|
{
|
84884
85374
|
continue;
|
84885
85375
|
}
|
84886
|
-
else if (
|
85376
|
+
else if (bounds2.bottom < bounds1.y)
|
84887
85377
|
{
|
84888
85378
|
break;
|
84889
85379
|
}
|
84890
85380
|
}
|
84891
85381
|
else if (this.sortDirection === Phaser.Physics.Arcade.BOTTOM_TOP)
|
84892
85382
|
{
|
84893
|
-
if (
|
85383
|
+
if (bounds1.y > bounds2.bottom)
|
84894
85384
|
{
|
84895
85385
|
continue;
|
84896
85386
|
}
|
84897
|
-
else if (
|
85387
|
+
else if (bounds2.y > object1.body.bottom)
|
84898
85388
|
{
|
84899
85389
|
break;
|
84900
85390
|
}
|
@@ -84967,6 +85457,42 @@ Phaser.Physics.Arcade.prototype = {
|
|
84967
85457
|
return false;
|
84968
85458
|
}
|
84969
85459
|
|
85460
|
+
// Circle vs. Circle quick bail out
|
85461
|
+
if (body1.isCircle && body2.isCircle)
|
85462
|
+
{
|
85463
|
+
return this.separateCircle(body1, body2, overlapOnly);
|
85464
|
+
}
|
85465
|
+
|
85466
|
+
// We define the behavior of bodies in a collision circle and rectangle
|
85467
|
+
// If a collision occurs in the corner points of the rectangle, the body behave like circles
|
85468
|
+
|
85469
|
+
// Either body1 or body2 is a circle
|
85470
|
+
if (body1.isCircle !== body2.isCircle)
|
85471
|
+
{
|
85472
|
+
var bodyRect = (body1.isCircle) ? body2 : body1;
|
85473
|
+
var bodyCircle = (body1.isCircle) ? body1 : body2;
|
85474
|
+
|
85475
|
+
var rect = {
|
85476
|
+
x: bodyRect.x,
|
85477
|
+
y: bodyRect.y,
|
85478
|
+
right: bodyRect.right,
|
85479
|
+
bottom: bodyRect.bottom
|
85480
|
+
};
|
85481
|
+
|
85482
|
+
var circle = {
|
85483
|
+
x: bodyCircle.x + bodyCircle.radius,
|
85484
|
+
y: bodyCircle.y + bodyCircle.radius
|
85485
|
+
};
|
85486
|
+
|
85487
|
+
if (circle.y < rect.y || circle.y > rect.bottom)
|
85488
|
+
{
|
85489
|
+
if (circle.x < rect.x || circle.x > rect.right)
|
85490
|
+
{
|
85491
|
+
return this.separateCircle(body1, body2, overlapOnly);
|
85492
|
+
}
|
85493
|
+
}
|
85494
|
+
}
|
85495
|
+
|
84970
85496
|
var resultX = false;
|
84971
85497
|
var resultY = false;
|
84972
85498
|
|
@@ -84992,7 +85518,37 @@ Phaser.Physics.Arcade.prototype = {
|
|
84992
85518
|
}
|
84993
85519
|
}
|
84994
85520
|
|
84995
|
-
|
85521
|
+
var result = (resultX || resultY);
|
85522
|
+
|
85523
|
+
if (result)
|
85524
|
+
{
|
85525
|
+
if (overlapOnly)
|
85526
|
+
{
|
85527
|
+
if (body1.onOverlap)
|
85528
|
+
{
|
85529
|
+
body1.onOverlap.dispatch(body1.sprite, body2.sprite);
|
85530
|
+
}
|
85531
|
+
|
85532
|
+
if (body2.onOverlap)
|
85533
|
+
{
|
85534
|
+
body2.onOverlap.dispatch(body2.sprite, body1.sprite);
|
85535
|
+
}
|
85536
|
+
}
|
85537
|
+
else
|
85538
|
+
{
|
85539
|
+
if (body1.onCollide)
|
85540
|
+
{
|
85541
|
+
body1.onCollide.dispatch(body1.sprite, body2.sprite);
|
85542
|
+
}
|
85543
|
+
|
85544
|
+
if (body2.onCollide)
|
85545
|
+
{
|
85546
|
+
body2.onCollide.dispatch(body2.sprite, body1.sprite);
|
85547
|
+
}
|
85548
|
+
}
|
85549
|
+
}
|
85550
|
+
|
85551
|
+
return result;
|
84996
85552
|
|
84997
85553
|
},
|
84998
85554
|
|
@@ -85010,26 +85566,253 @@ Phaser.Physics.Arcade.prototype = {
|
|
85010
85566
|
{
|
85011
85567
|
return false;
|
85012
85568
|
}
|
85013
|
-
|
85014
|
-
|
85015
|
-
if (body1.right <= body2.position.x)
|
85569
|
+
|
85570
|
+
if (body1.isCircle)
|
85016
85571
|
{
|
85017
|
-
|
85572
|
+
if (body2.isCircle)
|
85573
|
+
{
|
85574
|
+
// Circle vs. Circle
|
85575
|
+
return Phaser.Math.distance(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.radius + body2.radius);
|
85576
|
+
}
|
85577
|
+
else
|
85578
|
+
{
|
85579
|
+
// Circle vs. Rect
|
85580
|
+
return this.circleBodyIntersects(body1, body2);
|
85581
|
+
}
|
85582
|
+
}
|
85583
|
+
else
|
85584
|
+
{
|
85585
|
+
if (body2.isCircle)
|
85586
|
+
{
|
85587
|
+
// Rect vs. Circle
|
85588
|
+
return this.circleBodyIntersects(body2, body1);
|
85589
|
+
}
|
85590
|
+
else
|
85591
|
+
{
|
85592
|
+
// Rect vs. Rect
|
85593
|
+
if (body1.right <= body2.position.x)
|
85594
|
+
{
|
85595
|
+
return false;
|
85596
|
+
}
|
85597
|
+
|
85598
|
+
if (body1.bottom <= body2.position.y)
|
85599
|
+
{
|
85600
|
+
return false;
|
85601
|
+
}
|
85602
|
+
|
85603
|
+
if (body1.position.x >= body2.right)
|
85604
|
+
{
|
85605
|
+
return false;
|
85606
|
+
}
|
85607
|
+
|
85608
|
+
if (body1.position.y >= body2.bottom)
|
85609
|
+
{
|
85610
|
+
return false;
|
85611
|
+
}
|
85612
|
+
|
85613
|
+
return true;
|
85614
|
+
}
|
85018
85615
|
}
|
85019
85616
|
|
85020
|
-
|
85617
|
+
},
|
85618
|
+
|
85619
|
+
/**
|
85620
|
+
* Checks to see if a circular Body intersects with a Rectangular Body.
|
85621
|
+
*
|
85622
|
+
* @method Phaser.Physics.Arcade#circleBodyIntersects
|
85623
|
+
* @param {Phaser.Physics.Arcade.Body} circle - The Body with `isCircle` set.
|
85624
|
+
* @param {Phaser.Physics.Arcade.Body} body - The Body with `isCircle` not set (i.e. uses Rectangle shape)
|
85625
|
+
* @return {boolean} Returns true if the bodies intersect, otherwise false.
|
85626
|
+
*/
|
85627
|
+
circleBodyIntersects: function (circle, body) {
|
85628
|
+
|
85629
|
+
var x = Phaser.Math.clamp(circle.center.x, body.left, body.right);
|
85630
|
+
var y = Phaser.Math.clamp(circle.center.y, body.top, body.bottom);
|
85631
|
+
|
85632
|
+
var dx = (circle.center.x - x) * (circle.center.x - x);
|
85633
|
+
var dy = (circle.center.y - y) * (circle.center.y - y);
|
85634
|
+
|
85635
|
+
return (dx + dy) <= (circle.radius * circle.radius);
|
85636
|
+
|
85637
|
+
},
|
85638
|
+
|
85639
|
+
/**
|
85640
|
+
* The core separation function to separate two circular physics bodies.
|
85641
|
+
*
|
85642
|
+
* @method Phaser.Physics.Arcade#separateCircle
|
85643
|
+
* @private
|
85644
|
+
* @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. Must have `Body.isCircle` true and a positive `radius`.
|
85645
|
+
* @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate. Must have `Body.isCircle` true and a positive `radius`.
|
85646
|
+
* @param {boolean} overlapOnly - If true the bodies will only have their overlap data set, no separation or exchange of velocity will take place.
|
85647
|
+
* @return {boolean} Returns true if the bodies were separated or overlap, otherwise false.
|
85648
|
+
*/
|
85649
|
+
separateCircle: function (body1, body2, overlapOnly) {
|
85650
|
+
|
85651
|
+
// Set the bounding box overlap values
|
85652
|
+
this.getOverlapX(body1, body2);
|
85653
|
+
this.getOverlapY(body1, body2);
|
85654
|
+
|
85655
|
+
var angleCollision = this.angleBetweenCenters(body1, body2);
|
85656
|
+
|
85657
|
+
var overlap = 0;
|
85658
|
+
|
85659
|
+
if (body1.isCircle !== body2.isCircle)
|
85021
85660
|
{
|
85022
|
-
|
85661
|
+
var rect = {
|
85662
|
+
x: (body2.isCircle) ? body1.position.x : body2.position.x,
|
85663
|
+
y: (body2.isCircle) ? body1.position.y : body2.position.y,
|
85664
|
+
right: (body2.isCircle) ? body1.right : body2.right,
|
85665
|
+
bottom: (body2.isCircle) ? body1.bottom : body2.bottom
|
85666
|
+
};
|
85667
|
+
|
85668
|
+
var circle = {
|
85669
|
+
x: (body1.isCircle) ? (body1.position.x + body1.radius) : (body2.position.x + body2.radius),
|
85670
|
+
y: (body1.isCircle) ? (body1.position.y + body1.radius) : (body2.position.y + body2.radius),
|
85671
|
+
radius: (body1.isCircle) ? body1.radius : body2.radius
|
85672
|
+
};
|
85673
|
+
|
85674
|
+
if (circle.y < rect.y)
|
85675
|
+
{
|
85676
|
+
if (circle.x < rect.x)
|
85677
|
+
{
|
85678
|
+
overlap = Phaser.Math.distance(circle.x, circle.y, rect.x, rect.y) - circle.radius;
|
85679
|
+
}
|
85680
|
+
else if (circle.x > rect.right)
|
85681
|
+
{
|
85682
|
+
overlap = Phaser.Math.distance(circle.x, circle.y, rect.right, rect.y) - circle.radius;
|
85683
|
+
}
|
85684
|
+
}
|
85685
|
+
else if (circle.y > rect.bottom)
|
85686
|
+
{
|
85687
|
+
if (circle.x < rect.x)
|
85688
|
+
{
|
85689
|
+
overlap = Phaser.Math.distance(circle.x, circle.y, rect.x, rect.bottom) - circle.radius;
|
85690
|
+
}
|
85691
|
+
else if (circle.x > rect.right)
|
85692
|
+
{
|
85693
|
+
overlap = Phaser.Math.distance(circle.x, circle.y, rect.right, rect.bottom) - circle.radius;
|
85694
|
+
}
|
85695
|
+
}
|
85696
|
+
|
85697
|
+
overlap *= -1;
|
85698
|
+
}
|
85699
|
+
else
|
85700
|
+
{
|
85701
|
+
overlap = (body1.radius + body2.radius) - Phaser.Math.distance(body1.center.x, body1.center.y, body2.center.x, body2.center.y);
|
85023
85702
|
}
|
85024
85703
|
|
85025
|
-
|
85704
|
+
// Can't separate two immovable bodies, or a body with its own custom separation logic
|
85705
|
+
if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX)
|
85026
85706
|
{
|
85027
|
-
|
85707
|
+
if (overlap !== 0)
|
85708
|
+
{
|
85709
|
+
if (body1.onOverlap)
|
85710
|
+
{
|
85711
|
+
body1.onOverlap.dispatch(body1.sprite, body2.sprite);
|
85712
|
+
}
|
85713
|
+
|
85714
|
+
if (body2.onOverlap)
|
85715
|
+
{
|
85716
|
+
body2.onOverlap.dispatch(body2.sprite, body1.sprite);
|
85717
|
+
}
|
85718
|
+
}
|
85719
|
+
|
85720
|
+
// return true if there was some overlap, otherwise false
|
85721
|
+
return (overlap !== 0);
|
85722
|
+
}
|
85723
|
+
|
85724
|
+
// Transform the velocity vector to the coordinate system oriented along the direction of impact.
|
85725
|
+
// This is done to eliminate the vertical component of the velocity
|
85726
|
+
var v1 = {
|
85727
|
+
x: body1.velocity.x * Math.cos(angleCollision) + body1.velocity.y * Math.sin(angleCollision),
|
85728
|
+
y: body1.velocity.x * Math.sin(angleCollision) - body1.velocity.y * Math.cos(angleCollision)
|
85729
|
+
};
|
85730
|
+
|
85731
|
+
var v2 = {
|
85732
|
+
x: body2.velocity.x * Math.cos(angleCollision) + body2.velocity.y * Math.sin(angleCollision),
|
85733
|
+
y: body2.velocity.x * Math.sin(angleCollision) - body2.velocity.y * Math.cos(angleCollision)
|
85734
|
+
};
|
85735
|
+
|
85736
|
+
// We expect the new velocity after impact
|
85737
|
+
var tempVel1 = ((body1.mass - body2.mass) * v1.x + 2 * body2.mass * v2.x) / (body1.mass + body2.mass);
|
85738
|
+
var tempVel2 = (2 * body1.mass * v1.x + (body2.mass - body1.mass) * v2.x) / (body1.mass + body2.mass);
|
85739
|
+
|
85740
|
+
// We convert the vector to the original coordinate system and multiplied by factor of rebound
|
85741
|
+
if (!body1.immovable)
|
85742
|
+
{
|
85743
|
+
body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x;
|
85744
|
+
body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y;
|
85028
85745
|
}
|
85029
85746
|
|
85030
|
-
if (
|
85747
|
+
if (!body2.immovable)
|
85031
85748
|
{
|
85032
|
-
|
85749
|
+
body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x;
|
85750
|
+
body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y;
|
85751
|
+
}
|
85752
|
+
|
85753
|
+
// When the collision angle is almost perpendicular to the total initial velocity vector
|
85754
|
+
// (collision on a tangent) vector direction can be determined incorrectly.
|
85755
|
+
// This code fixes the problem
|
85756
|
+
|
85757
|
+
if (Math.abs(angleCollision) < Math.PI / 2)
|
85758
|
+
{
|
85759
|
+
if ((body1.velocity.x > 0) && !body1.immovable && (body2.velocity.x > body1.velocity.x))
|
85760
|
+
{
|
85761
|
+
body1.velocity.x *= -1;
|
85762
|
+
}
|
85763
|
+
else if ((body2.velocity.x < 0) && !body2.immovable && (body1.velocity.x < body2.velocity.x))
|
85764
|
+
{
|
85765
|
+
body2.velocity.x *= -1;
|
85766
|
+
}
|
85767
|
+
else if ((body1.velocity.y > 0) && !body1.immovable && (body2.velocity.y > body1.velocity.y))
|
85768
|
+
{
|
85769
|
+
body1.velocity.y *= -1;
|
85770
|
+
}
|
85771
|
+
else if ((body2.velocity.y < 0) && !body2.immovable && (body1.velocity.y < body2.velocity.y))
|
85772
|
+
{
|
85773
|
+
body2.velocity.y *= -1;
|
85774
|
+
}
|
85775
|
+
}
|
85776
|
+
else if (Math.abs(angleCollision) > Math.PI / 2)
|
85777
|
+
{
|
85778
|
+
if ((body1.velocity.x < 0) && !body1.immovable && (body2.velocity.x < body1.velocity.x))
|
85779
|
+
{
|
85780
|
+
body1.velocity.x *= -1;
|
85781
|
+
}
|
85782
|
+
else if ((body2.velocity.x > 0) && !body2.immovable && (body1.velocity.x > body2.velocity.x))
|
85783
|
+
{
|
85784
|
+
body2.velocity.x *= -1;
|
85785
|
+
}
|
85786
|
+
else if ((body1.velocity.y < 0) && !body1.immovable && (body2.velocity.y < body1.velocity.y))
|
85787
|
+
{
|
85788
|
+
body1.velocity.y *= -1;
|
85789
|
+
}
|
85790
|
+
else if ((body2.velocity.y > 0) && !body2.immovable && (body1.velocity.x > body2.velocity.y))
|
85791
|
+
{
|
85792
|
+
body2.velocity.y *= -1;
|
85793
|
+
}
|
85794
|
+
}
|
85795
|
+
|
85796
|
+
if (!body1.immovable)
|
85797
|
+
{
|
85798
|
+
body1.x += (body1.velocity.x * this.game.time.physicsElapsed) - overlap * Math.cos(angleCollision);
|
85799
|
+
body1.y += (body1.velocity.y * this.game.time.physicsElapsed) - overlap * Math.sin(angleCollision);
|
85800
|
+
}
|
85801
|
+
|
85802
|
+
if (!body2.immovable)
|
85803
|
+
{
|
85804
|
+
body2.x += (body2.velocity.x * this.game.time.physicsElapsed) + overlap * Math.cos(angleCollision);
|
85805
|
+
body2.y += (body2.velocity.y * this.game.time.physicsElapsed) + overlap * Math.sin(angleCollision);
|
85806
|
+
}
|
85807
|
+
|
85808
|
+
if (body1.onCollide)
|
85809
|
+
{
|
85810
|
+
body1.onCollide.dispatch(body1.sprite, body2.sprite);
|
85811
|
+
}
|
85812
|
+
|
85813
|
+
if (body2.onCollide)
|
85814
|
+
{
|
85815
|
+
body2.onCollide.dispatch(body2.sprite, body1.sprite);
|
85033
85816
|
}
|
85034
85817
|
|
85035
85818
|
return true;
|
@@ -85729,6 +86512,23 @@ Phaser.Physics.Arcade.prototype = {
|
|
85729
86512
|
|
85730
86513
|
},
|
85731
86514
|
|
86515
|
+
/**
|
86516
|
+
* Find the angle in radians between centers of two display objects (like Sprites).
|
86517
|
+
*
|
86518
|
+
* @method Phaser.Physics.Arcade#angleBetweenCenters
|
86519
|
+
* @param {any} source - The Display Object to test from.
|
86520
|
+
* @param {any} target - The Display Object to test to.
|
86521
|
+
* @return {number} The angle in radians between the source and target display objects.
|
86522
|
+
*/
|
86523
|
+
angleBetweenCenters: function (source, target) {
|
86524
|
+
|
86525
|
+
var dx = target.center.x - source.center.x;
|
86526
|
+
var dy = target.center.y - source.center.y;
|
86527
|
+
|
86528
|
+
return Math.atan2(dy, dx);
|
86529
|
+
|
86530
|
+
},
|
86531
|
+
|
85732
86532
|
/**
|
85733
86533
|
* Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate.
|
85734
86534
|
*
|
@@ -85841,6 +86641,25 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|
85841
86641
|
*/
|
85842
86642
|
this.enable = true;
|
85843
86643
|
|
86644
|
+
/**
|
86645
|
+
* If `true` this Body is using circular collision detection. If `false` it is using rectangular.
|
86646
|
+
* Use `Body.setCircle` to control the collision shape this Body uses.
|
86647
|
+
* @property {boolean} isCircle
|
86648
|
+
* @default
|
86649
|
+
* @readOnly
|
86650
|
+
*/
|
86651
|
+
this.isCircle = false;
|
86652
|
+
|
86653
|
+
/**
|
86654
|
+
* The radius of the circular collision shape this Body is using if Body.setCircle has been enabled.
|
86655
|
+
* If you wish to change the radius then call `setCircle` again with the new value.
|
86656
|
+
* If you wish to stop the Body using a circle then call `setCircle` with a radius of zero (or undefined).
|
86657
|
+
* @property {number} radius
|
86658
|
+
* @default
|
86659
|
+
* @readOnly
|
86660
|
+
*/
|
86661
|
+
this.radius = 0;
|
86662
|
+
|
85844
86663
|
/**
|
85845
86664
|
* @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
|
85846
86665
|
*/
|
@@ -85934,12 +86753,12 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|
85934
86753
|
* @property {Phaser.Point} newVelocity - The new velocity. Calculated during the Body.preUpdate and applied to its position.
|
85935
86754
|
* @readonly
|
85936
86755
|
*/
|
85937
|
-
this.newVelocity = new Phaser.Point(
|
86756
|
+
this.newVelocity = new Phaser.Point();
|
85938
86757
|
|
85939
86758
|
/**
|
85940
86759
|
* @property {Phaser.Point} deltaMax - The Sprite position is updated based on the delta x/y values. You can set a cap on those (both +-) using deltaMax.
|
85941
86760
|
*/
|
85942
|
-
this.deltaMax = new Phaser.Point(
|
86761
|
+
this.deltaMax = new Phaser.Point();
|
85943
86762
|
|
85944
86763
|
/**
|
85945
86764
|
* @property {Phaser.Point} acceleration - The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
|
@@ -85960,7 +86779,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|
85960
86779
|
/**
|
85961
86780
|
* @property {Phaser.Point} gravity - A local gravity applied to this Body. If non-zero this over rides any world gravity, unless Body.allowGravity is set to false.
|
85962
86781
|
*/
|
85963
|
-
this.gravity = new Phaser.Point(
|
86782
|
+
this.gravity = new Phaser.Point();
|
85964
86783
|
|
85965
86784
|
/**
|
85966
86785
|
* @property {Phaser.Point} bounce - The elasticity of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.
|
@@ -85975,6 +86794,58 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|
85975
86794
|
*/
|
85976
86795
|
this.worldBounce = null;
|
85977
86796
|
|
86797
|
+
/**
|
86798
|
+
* A Signal that is dispatched when this Body collides with the world bounds.
|
86799
|
+
* Due to the potentially high volume of signals this could create it is disabled by default.
|
86800
|
+
* To use this feature set this property to a Phaser.Signal: `sprite.body.onWorldBounds = new Phaser.Signal()`
|
86801
|
+
* and it will be called when a collision happens, passing five arguments:
|
86802
|
+
* `onWorldBounds(sprite, up, down, left, right)`
|
86803
|
+
* where the Sprite is a reference to the Sprite that owns this Body, and the other arguments are booleans
|
86804
|
+
* indicating on which side of the world the Body collided.
|
86805
|
+
* @property {Phaser.Signal} onWorldBounds
|
86806
|
+
*/
|
86807
|
+
this.onWorldBounds = null;
|
86808
|
+
|
86809
|
+
/**
|
86810
|
+
* A Signal that is dispatched when this Body collides with another Body.
|
86811
|
+
*
|
86812
|
+
* You still need to call `game.physics.arcade.collide` in your `update` method in order
|
86813
|
+
* for this signal to be dispatched.
|
86814
|
+
*
|
86815
|
+
* Usually you'd pass a callback to the `collide` method, but this signal provides for
|
86816
|
+
* a different level of notification.
|
86817
|
+
*
|
86818
|
+
* Due to the potentially high volume of signals this could create it is disabled by default.
|
86819
|
+
*
|
86820
|
+
* To use this feature set this property to a Phaser.Signal: `sprite.body.onCollide = new Phaser.Signal()`
|
86821
|
+
* and it will be called when a collision happens, passing two arguments: the sprites which collided.
|
86822
|
+
* The first sprite in the argument is always the owner of this Body.
|
86823
|
+
*
|
86824
|
+
* If two Bodies with this Signal set collide, both will dispatch the Signal.
|
86825
|
+
* @property {Phaser.Signal} onCollide
|
86826
|
+
*/
|
86827
|
+
this.onCollide = null;
|
86828
|
+
|
86829
|
+
/**
|
86830
|
+
* A Signal that is dispatched when this Body overlaps with another Body.
|
86831
|
+
*
|
86832
|
+
* You still need to call `game.physics.arcade.overlap` in your `update` method in order
|
86833
|
+
* for this signal to be dispatched.
|
86834
|
+
*
|
86835
|
+
* Usually you'd pass a callback to the `overlap` method, but this signal provides for
|
86836
|
+
* a different level of notification.
|
86837
|
+
*
|
86838
|
+
* Due to the potentially high volume of signals this could create it is disabled by default.
|
86839
|
+
*
|
86840
|
+
* To use this feature set this property to a Phaser.Signal: `sprite.body.onOverlap = new Phaser.Signal()`
|
86841
|
+
* and it will be called when a collision happens, passing two arguments: the sprites which collided.
|
86842
|
+
* The first sprite in the argument is always the owner of this Body.
|
86843
|
+
*
|
86844
|
+
* If two Bodies with this Signal set collide, both will dispatch the Signal.
|
86845
|
+
* @property {Phaser.Signal} onOverlap
|
86846
|
+
*/
|
86847
|
+
this.onOverlap = null;
|
86848
|
+
|
85978
86849
|
/**
|
85979
86850
|
* @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach.
|
85980
86851
|
* @default
|
@@ -86077,6 +86948,12 @@ Phaser.Physics.Arcade.Body = function (sprite) {
|
|
86077
86948
|
*/
|
86078
86949
|
this.overlapY = 0;
|
86079
86950
|
|
86951
|
+
/**
|
86952
|
+
* If `Body.isCircle` is true, and this body collides with another circular body, the amount of overlap is stored here.
|
86953
|
+
* @property {number} overlapR - The amount of overlap during the collision.
|
86954
|
+
*/
|
86955
|
+
this.overlapR = 0;
|
86956
|
+
|
86080
86957
|
/**
|
86081
86958
|
* If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true.
|
86082
86959
|
* @property {boolean} embedded - Body embed value.
|
@@ -86350,7 +87227,10 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86350
87227
|
|
86351
87228
|
if (this.collideWorldBounds)
|
86352
87229
|
{
|
86353
|
-
this.checkWorldBounds()
|
87230
|
+
if (this.checkWorldBounds() && this.onWorldBounds)
|
87231
|
+
{
|
87232
|
+
this.onWorldBounds.dispatch(this.sprite, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right);
|
87233
|
+
}
|
86354
87234
|
}
|
86355
87235
|
}
|
86356
87236
|
|
@@ -86521,6 +87401,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86521
87401
|
*
|
86522
87402
|
* @method Phaser.Physics.Arcade.Body#checkWorldBounds
|
86523
87403
|
* @protected
|
87404
|
+
* @return {boolean} True if the Body collided with the world bounds, otherwise false.
|
86524
87405
|
*/
|
86525
87406
|
checkWorldBounds: function () {
|
86526
87407
|
|
@@ -86531,32 +87412,72 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86531
87412
|
var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x;
|
86532
87413
|
var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y;
|
86533
87414
|
|
86534
|
-
if (
|
86535
|
-
{
|
86536
|
-
pos.x = bounds.x;
|
86537
|
-
this.velocity.x *= bx;
|
86538
|
-
this.blocked.left = true;
|
86539
|
-
}
|
86540
|
-
else if (this.right > bounds.right && check.right)
|
87415
|
+
if (this.isCircle)
|
86541
87416
|
{
|
86542
|
-
|
86543
|
-
|
86544
|
-
|
86545
|
-
|
87417
|
+
var bodyBounds = {
|
87418
|
+
x: this.center.x - this.radius,
|
87419
|
+
y: this.center.y - this.radius,
|
87420
|
+
right: this.center.x + this.radius,
|
87421
|
+
bottom: this.center.y + this.radius
|
87422
|
+
};
|
86546
87423
|
|
86547
|
-
|
86548
|
-
|
86549
|
-
|
86550
|
-
|
86551
|
-
|
87424
|
+
if (bodyBounds.x < bounds.x && check.left)
|
87425
|
+
{
|
87426
|
+
pos.x = bounds.x - this.halfWidth + this.radius;
|
87427
|
+
this.velocity.x *= bx;
|
87428
|
+
this.blocked.left = true;
|
87429
|
+
}
|
87430
|
+
else if (bodyBounds.right > bounds.right && check.right)
|
87431
|
+
{
|
87432
|
+
pos.x = bounds.right - this.halfWidth - this.radius;
|
87433
|
+
this.velocity.x *= bx;
|
87434
|
+
this.blocked.right = true;
|
87435
|
+
}
|
87436
|
+
|
87437
|
+
if (bodyBounds.y < bounds.y && check.up)
|
87438
|
+
{
|
87439
|
+
pos.y = bounds.y - this.halfHeight + this.radius;
|
87440
|
+
this.velocity.y *= by;
|
87441
|
+
this.blocked.up = true;
|
87442
|
+
}
|
87443
|
+
else if (bodyBounds.bottom > bounds.bottom && check.down)
|
87444
|
+
{
|
87445
|
+
pos.y = bounds.bottom - this.halfHeight - this.radius;
|
87446
|
+
this.velocity.y *= by;
|
87447
|
+
this.blocked.down = true;
|
87448
|
+
}
|
86552
87449
|
}
|
86553
|
-
else
|
87450
|
+
else
|
86554
87451
|
{
|
86555
|
-
pos.
|
86556
|
-
|
86557
|
-
|
87452
|
+
if (pos.x < bounds.x && check.left)
|
87453
|
+
{
|
87454
|
+
pos.x = bounds.x;
|
87455
|
+
this.velocity.x *= bx;
|
87456
|
+
this.blocked.left = true;
|
87457
|
+
}
|
87458
|
+
else if (this.right > bounds.right && check.right)
|
87459
|
+
{
|
87460
|
+
pos.x = bounds.right - this.width;
|
87461
|
+
this.velocity.x *= bx;
|
87462
|
+
this.blocked.right = true;
|
87463
|
+
}
|
87464
|
+
|
87465
|
+
if (pos.y < bounds.y && check.up)
|
87466
|
+
{
|
87467
|
+
pos.y = bounds.y;
|
87468
|
+
this.velocity.y *= by;
|
87469
|
+
this.blocked.up = true;
|
87470
|
+
}
|
87471
|
+
else if (this.bottom > bounds.bottom && check.down)
|
87472
|
+
{
|
87473
|
+
pos.y = bounds.bottom - this.height;
|
87474
|
+
this.velocity.y *= by;
|
87475
|
+
this.blocked.down = true;
|
87476
|
+
}
|
86558
87477
|
}
|
86559
87478
|
|
87479
|
+
return (this.blocked.up || this.blocked.down || this.blocked.left || this.blocked.right);
|
87480
|
+
|
86560
87481
|
},
|
86561
87482
|
|
86562
87483
|
/**
|
@@ -86735,6 +87656,9 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86735
87656
|
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
|
86736
87657
|
* is the vertical offset.
|
86737
87658
|
*
|
87659
|
+
* Calling `setSize` on a Body that has already had `setCircle` will reset all of the Circle
|
87660
|
+
* properties, making this Body rectangular again.
|
87661
|
+
*
|
86738
87662
|
* @method Phaser.Physics.Arcade.Body#setSize
|
86739
87663
|
* @param {number} width - The width of the Body.
|
86740
87664
|
* @param {number} height - The height of the Body.
|
@@ -86756,6 +87680,55 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86756
87680
|
|
86757
87681
|
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
|
86758
87682
|
|
87683
|
+
this.isCircle = false;
|
87684
|
+
this.radius = 0;
|
87685
|
+
|
87686
|
+
},
|
87687
|
+
|
87688
|
+
/**
|
87689
|
+
* Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle.
|
87690
|
+
* The radius is given in pixels and is the distance from the center of the circle to the edge.
|
87691
|
+
*
|
87692
|
+
* You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite.
|
87693
|
+
*
|
87694
|
+
* To change a Body back to being rectangular again call `Body.setSize`.
|
87695
|
+
*
|
87696
|
+
* Note: Circular collision only happens with other Arcade Physics bodies, it does not
|
87697
|
+
* work against tile maps, where rectangular collision is the only method supported.
|
87698
|
+
*
|
87699
|
+
* @method Phaser.Physics.Arcade.Body#setCircle
|
87700
|
+
* @param {number} [radius] - The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision.
|
87701
|
+
* @param {number} [offsetX] - The X offset of the Body from the Sprite position.
|
87702
|
+
* @param {number} [offsetY] - The Y offset of the Body from the Sprite position.
|
87703
|
+
*/
|
87704
|
+
setCircle: function (radius, offsetX, offsetY) {
|
87705
|
+
|
87706
|
+
if (offsetX === undefined) { offsetX = this.offset.x; }
|
87707
|
+
if (offsetY === undefined) { offsetY = this.offset.y; }
|
87708
|
+
|
87709
|
+
if (radius > 0)
|
87710
|
+
{
|
87711
|
+
this.isCircle = true;
|
87712
|
+
this.radius = radius;
|
87713
|
+
|
87714
|
+
this.sourceWidth = radius * 2;
|
87715
|
+
this.sourceHeight = radius * 2;
|
87716
|
+
|
87717
|
+
this.width = this.sourceWidth * this._sx;
|
87718
|
+
this.height = this.sourceHeight * this._sy;
|
87719
|
+
|
87720
|
+
this.halfWidth = Math.floor(this.width / 2);
|
87721
|
+
this.halfHeight = Math.floor(this.height / 2);
|
87722
|
+
|
87723
|
+
this.offset.setTo(offsetX, offsetY);
|
87724
|
+
|
87725
|
+
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
|
87726
|
+
}
|
87727
|
+
else
|
87728
|
+
{
|
87729
|
+
this.isCircle = false;
|
87730
|
+
}
|
87731
|
+
|
86759
87732
|
},
|
86760
87733
|
|
86761
87734
|
/**
|
@@ -86793,6 +87766,36 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86793
87766
|
|
86794
87767
|
},
|
86795
87768
|
|
87769
|
+
/**
|
87770
|
+
* Returns the bounds of this physics body.
|
87771
|
+
*
|
87772
|
+
* Only used internally by the World collision methods.
|
87773
|
+
*
|
87774
|
+
* @method Phaser.Physics.Arcade.Body#getBounds
|
87775
|
+
* @param {object} obj - The object in which to set the bounds values.
|
87776
|
+
* @return {object} The object that was given to this method.
|
87777
|
+
*/
|
87778
|
+
getBounds: function (obj) {
|
87779
|
+
|
87780
|
+
if (this.isCircle)
|
87781
|
+
{
|
87782
|
+
obj.x = this.center.x - this.radius;
|
87783
|
+
obj.y = this.center.y - this.radius;
|
87784
|
+
obj.right = this.center.x + this.radius;
|
87785
|
+
obj.bottom = this.center.y + this.radius;
|
87786
|
+
}
|
87787
|
+
else
|
87788
|
+
{
|
87789
|
+
obj.x = this.x;
|
87790
|
+
obj.y = this.y;
|
87791
|
+
obj.right = this.right;
|
87792
|
+
obj.bottom = this.bottom;
|
87793
|
+
}
|
87794
|
+
|
87795
|
+
return obj;
|
87796
|
+
|
87797
|
+
},
|
87798
|
+
|
86796
87799
|
/**
|
86797
87800
|
* Tests if a world point lies within this Body.
|
86798
87801
|
*
|
@@ -86803,7 +87806,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|
86803
87806
|
*/
|
86804
87807
|
hitTest: function (x, y) {
|
86805
87808
|
|
86806
|
-
return Phaser.Rectangle.contains(this, x, y);
|
87809
|
+
return (this.isCircle) ? Phaser.Circle.contains(this, x, y) : Phaser.Rectangle.contains(this, x, y);
|
86807
87810
|
|
86808
87811
|
},
|
86809
87812
|
|
@@ -87037,15 +88040,33 @@ Phaser.Physics.Arcade.Body.render = function (context, body, color, filled) {
|
|
87037
88040
|
|
87038
88041
|
color = color || 'rgba(0,255,0,0.4)';
|
87039
88042
|
|
87040
|
-
|
88043
|
+
context.fillStyle = color;
|
88044
|
+
context.strokeStyle = color;
|
88045
|
+
|
88046
|
+
if (body.isCircle)
|
87041
88047
|
{
|
87042
|
-
context.
|
87043
|
-
context.
|
88048
|
+
context.beginPath();
|
88049
|
+
context.arc(body.center.x - body.game.camera.x, body.center.y - body.game.camera.y, body.radius, 0, 2 * Math.PI);
|
88050
|
+
|
88051
|
+
if (filled)
|
88052
|
+
{
|
88053
|
+
context.fill();
|
88054
|
+
}
|
88055
|
+
else
|
88056
|
+
{
|
88057
|
+
context.stroke();
|
88058
|
+
}
|
87044
88059
|
}
|
87045
88060
|
else
|
87046
88061
|
{
|
87047
|
-
|
87048
|
-
|
88062
|
+
if (filled)
|
88063
|
+
{
|
88064
|
+
context.fillRect(body.position.x - body.game.camera.x, body.position.y - body.game.camera.y, body.width, body.height);
|
88065
|
+
}
|
88066
|
+
else
|
88067
|
+
{
|
88068
|
+
context.strokeRect(body.position.x - body.game.camera.x, body.position.y - body.game.camera.y, body.width, body.height);
|
88069
|
+
}
|
87049
88070
|
}
|
87050
88071
|
|
87051
88072
|
};
|
@@ -88201,13 +89222,13 @@ Phaser.Physics.P2.prototype = {
|
|
88201
89222
|
this.walls[wall] = new p2.Body({ mass: 0, position: [ this.pxmi(x), this.pxmi(y) ], angle: angle });
|
88202
89223
|
this.walls[wall].addShape(new p2.Plane());
|
88203
89224
|
|
88204
|
-
if (setCollisionGroup)
|
88205
|
-
{
|
88206
|
-
this.walls[wall].shapes[0].collisionGroup = this.boundsCollisionGroup.mask;
|
88207
|
-
}
|
88208
|
-
|
88209
89225
|
this.world.addBody(this.walls[wall]);
|
88210
89226
|
}
|
89227
|
+
|
89228
|
+
if (setCollisionGroup)
|
89229
|
+
{
|
89230
|
+
this.walls[wall].shapes[0].collisionGroup = this.boundsCollisionGroup.mask;
|
89231
|
+
}
|
88211
89232
|
}
|
88212
89233
|
else
|
88213
89234
|
{
|
@@ -88356,6 +89377,9 @@ Phaser.Physics.P2.prototype = {
|
|
88356
89377
|
this._toRemove = [];
|
88357
89378
|
this.boundsCollidesWith = [];
|
88358
89379
|
|
89380
|
+
// Remove the world bounds
|
89381
|
+
this.walls = { left: null, right: null, top: null, bottom: null };
|
89382
|
+
|
88359
89383
|
},
|
88360
89384
|
|
88361
89385
|
/**
|
@@ -96243,8 +97267,6 @@ Phaser.TilemapLayer.prototype.renderRegion = function (scrollX, scrollY, left, t
|
|
96243
97267
|
// xmax/ymax - remaining cells to render on column/row
|
96244
97268
|
var tx, ty, x, y, xmax, ymax;
|
96245
97269
|
|
96246
|
-
context.fillStyle = this.tileColor;
|
96247
|
-
|
96248
97270
|
for (y = normStartY, ymax = bottom - top, ty = baseY;
|
96249
97271
|
ymax >= 0;
|
96250
97272
|
y++, ymax--, ty += th)
|
@@ -96746,6 +97768,33 @@ Phaser.TilemapParser = {
|
|
96746
97768
|
*/
|
96747
97769
|
INSERT_NULL: false,
|
96748
97770
|
|
97771
|
+
/**
|
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
|
+
|
96749
97798
|
/**
|
96750
97799
|
* Parse tilemap data from the cache and creates a Tilemap object.
|
96751
97800
|
*
|
@@ -97226,6 +98275,8 @@ Phaser.TilemapParser = {
|
|
97226
98275
|
// Object Tiles
|
97227
98276
|
if (curo.objects[v].gid)
|
97228
98277
|
{
|
98278
|
+
var self = this;
|
98279
|
+
|
97229
98280
|
var object = {
|
97230
98281
|
|
97231
98282
|
gid: curo.objects[v].gid,
|
@@ -97233,9 +98284,13 @@ Phaser.TilemapParser = {
|
|
97233
98284
|
type: curo.objects[v].hasOwnProperty("type") ? curo.objects[v].type : "",
|
97234
98285
|
x: curo.objects[v].x,
|
97235
98286
|
y: curo.objects[v].y,
|
98287
|
+
width: curo.objects[v].width,
|
98288
|
+
height: curo.objects[v].height,
|
97236
98289
|
visible: curo.objects[v].visible,
|
97237
|
-
properties: curo.objects[v].properties
|
97238
|
-
|
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
|
97239
98294
|
};
|
97240
98295
|
|
97241
98296
|
if (curo.objects[v].rotation)
|
@@ -99025,7 +100080,7 @@ Phaser.Weapon = function (game, parent) {
|
|
99025
100080
|
this.fireFrom = new Phaser.Rectangle(0, 0, 1, 1);
|
99026
100081
|
|
99027
100082
|
/**
|
99028
|
-
* The angle at which the bullets are fired. This can be a const such as Phaser.ANGLE_UP
|
100083
|
+
* The angle at which the bullets are fired. This can be a const such as Phaser.ANGLE_UP
|
99029
100084
|
* or it can be any number from 0 to 360 inclusive, where 0 degrees is to the right.
|
99030
100085
|
* @type {integer}
|
99031
100086
|
*/
|
@@ -99103,14 +100158,14 @@ Phaser.Weapon = function (game, parent) {
|
|
99103
100158
|
|
99104
100159
|
/**
|
99105
100160
|
* This is a variance added to the speed of Bullets when they are fired.
|
99106
|
-
* If bullets have a `bulletSpeed` value of 200, and a `bulletSpeedVariance` of 50
|
100161
|
+
* If bullets have a `bulletSpeed` value of 200, and a `bulletSpeedVariance` of 50
|
99107
100162
|
* then the actual speed of the Bullets will be between 150 and 250 pixels per second.
|
99108
100163
|
* @type {number}
|
99109
100164
|
*/
|
99110
100165
|
this.bulletSpeedVariance = 0;
|
99111
100166
|
|
99112
100167
|
/**
|
99113
|
-
* If you've set `bulletKillType` to `Phaser.Weapon.KILL_LIFESPAN` this controls the amount
|
100168
|
+
* If you've set `bulletKillType` to `Phaser.Weapon.KILL_LIFESPAN` this controls the amount
|
99114
100169
|
* of lifespan the Bullets have set on launch. The value is given in milliseconds.
|
99115
100170
|
* When a Bullet hits its lifespan limit it will be automatically killed.
|
99116
100171
|
* @type {number}
|
@@ -99118,7 +100173,7 @@ Phaser.Weapon = function (game, parent) {
|
|
99118
100173
|
this.bulletLifespan = 0;
|
99119
100174
|
|
99120
100175
|
/**
|
99121
|
-
* If you've set `bulletKillType` to `Phaser.Weapon.KILL_DISTANCE` this controls the distance
|
100176
|
+
* If you've set `bulletKillType` to `Phaser.Weapon.KILL_DISTANCE` this controls the distance
|
99122
100177
|
* the Bullet can travel before it is automatically killed. The distance is given in pixels.
|
99123
100178
|
* @type {number}
|
99124
100179
|
*/
|
@@ -99192,7 +100247,7 @@ Phaser.Weapon = function (game, parent) {
|
|
99192
100247
|
* This Rectangle defines the bounds that are used when determining if a Bullet should be killed or not.
|
99193
100248
|
* It's used in combination with `Weapon.bulletKillType` when that is set to either `Phaser.Weapon.KILL_WEAPON_BOUNDS`
|
99194
100249
|
* or `Phaser.Weapon.KILL_STATIC_BOUNDS`. If you are not using either of these kill types then the bounds are ignored.
|
99195
|
-
* If you are tracking a Sprite or Point then the bounds are centered on that object every frame.
|
100250
|
+
* If you are tracking a Sprite or Point then the bounds are centered on that object every frame.
|
99196
100251
|
*
|
99197
100252
|
* @type {Phaser.Rectangle}
|
99198
100253
|
*/
|
@@ -99231,8 +100286,8 @@ Phaser.Weapon = function (game, parent) {
|
|
99231
100286
|
|
99232
100287
|
/**
|
99233
100288
|
* The onFire Signal is dispatched each time `Weapon.fire` is called, and a Bullet is
|
99234
|
-
* _successfully_ launched. The callback is set two arguments: a reference to the
|
99235
|
-
* and a reference to the
|
100289
|
+
* _successfully_ launched. The callback is set two arguments: a reference to the bullet sprite itself,
|
100290
|
+
* and a reference to the Weapon that fired the bullet.
|
99236
100291
|
*
|
99237
100292
|
* @type {Phaser.Signal}
|
99238
100293
|
*/
|
@@ -99320,7 +100375,7 @@ Phaser.Weapon.KILL_NEVER = 0;
|
|
99320
100375
|
Phaser.Weapon.KILL_LIFESPAN = 1;
|
99321
100376
|
|
99322
100377
|
/**
|
99323
|
-
* A `bulletKillType` constant that automatically kills the bullets after they
|
100378
|
+
* A `bulletKillType` constant that automatically kills the bullets after they
|
99324
100379
|
* exceed the `bulletDistance` from their original firing position.
|
99325
100380
|
* @constant
|
99326
100381
|
* @type {integer}
|
@@ -99371,7 +100426,7 @@ Phaser.Weapon.KILL_STATIC_BOUNDS = 6;
|
|
99371
100426
|
* so be careful it doesn't grow too large.
|
99372
100427
|
*
|
99373
100428
|
* You can either set the texture key and frame here, or via the `Weapon.bulletKey` and `Weapon.bulletFrame`
|
99374
|
-
* properties. You can also animate bullets, or set them to use random frames. All Bullets belonging to a
|
100429
|
+
* properties. You can also animate bullets, or set them to use random frames. All Bullets belonging to a
|
99375
100430
|
* single Weapon instance must share the same texture key however.
|
99376
100431
|
*
|
99377
100432
|
* @method Phaser.Weapon#createBullets
|
@@ -99399,7 +100454,7 @@ Phaser.Weapon.prototype.createBullets = function (quantity, key, frame, group) {
|
|
99399
100454
|
this.autoExpandBulletsGroup = true;
|
99400
100455
|
quantity = 1;
|
99401
100456
|
}
|
99402
|
-
|
100457
|
+
|
99403
100458
|
this.bullets.createMultiple(quantity, key, frame);
|
99404
100459
|
|
99405
100460
|
this.bullets.setAll('data.bulletManager', this);
|
@@ -99617,7 +100672,7 @@ Phaser.Weapon.prototype.trackPointer = function (pointer, offsetX, offsetY) {
|
|
99617
100672
|
* Attempts to fire a single Bullet. If there are no more bullets available in the pool, and the pool cannot be extended,
|
99618
100673
|
* then this method returns `false`. It will also return false if not enough time has expired since the last time
|
99619
100674
|
* the Weapon was fired, as defined in the `Weapon.fireRate` property.
|
99620
|
-
*
|
100675
|
+
*
|
99621
100676
|
* Otherwise the first available bullet is selected and launched.
|
99622
100677
|
*
|
99623
100678
|
* The arguments are all optional, but allow you to control both where the bullet is launched from, and aimed at.
|
@@ -99905,12 +100960,12 @@ Phaser.Weapon.prototype.setBulletBodyOffset = function (width, height, offsetX,
|
|
99905
100960
|
|
99906
100961
|
/**
|
99907
100962
|
* Sets the texture frames that the bullets can use when being launched.
|
99908
|
-
*
|
100963
|
+
*
|
99909
100964
|
* This is intended for use when you've got numeric based frames, such as those loaded via a Sprite Sheet.
|
99910
|
-
*
|
100965
|
+
*
|
99911
100966
|
* It works by calling `Phaser.ArrayUtils.numberArray` internally, using the min and max values
|
99912
100967
|
* provided. Then it sets the frame index to be zero.
|
99913
|
-
*
|
100968
|
+
*
|
99914
100969
|
* You can optionally set the cycle and random booleans, to allow bullets to cycle through the frames
|
99915
100970
|
* when they're fired, or pick one at random.
|
99916
100971
|
*
|
@@ -100035,10 +101090,10 @@ Object.defineProperty(Phaser.Weapon.prototype, "bulletClass", {
|
|
100035
101090
|
*
|
100036
101091
|
* * `Phaser.Weapon.KILL_LIFESPAN`
|
100037
101092
|
* The bullets are automatically killed when their `bulletLifespan` amount expires.
|
100038
|
-
*
|
101093
|
+
*
|
100039
101094
|
* * `Phaser.Weapon.KILL_DISTANCE`
|
100040
101095
|
* The bullets are automatically killed when they exceed `bulletDistance` pixels away from their original launch position.
|
100041
|
-
*
|
101096
|
+
*
|
100042
101097
|
* * `Phaser.Weapon.KILL_WEAPON_BOUNDS`
|
100043
101098
|
* The bullets are automatically killed when they no longer intersect with the `Weapon.bounds` rectangle.
|
100044
101099
|
*
|
@@ -100513,7 +101568,7 @@ Phaser.Video = function (game, key, url) {
|
|
100513
101568
|
}
|
100514
101569
|
else
|
100515
101570
|
{
|
100516
|
-
this.baseTexture = new PIXI.BaseTexture(
|
101571
|
+
this.baseTexture = new PIXI.BaseTexture(Phaser.Cache.DEFAULT.baseTexture.source);
|
100517
101572
|
this.baseTexture.forceLoaded(this.width, this.height);
|
100518
101573
|
}
|
100519
101574
|
|