You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* By Richard Davey http://www.photonstorm.com @photonstorm
9708
9708
*
@@ -15964,6 +15964,31 @@ Phaser.Group.prototype.updateZ = function () {
15964
15964
15965
15965
};
15966
15966
15967
+
/**
15968
+
* Sets the Group cursor to the first object in the Group. If the optional index parameter is given it sets the cursor to the object at that index instead.
15969
+
*
15970
+
* @method Phaser.Group#resetCursor
15971
+
* @param {number} [index=0] - Set the cursor to point to a specific index.
15972
+
* @return {*} The child the cursor now points to.
15973
+
*/
15974
+
Phaser.Group.prototype.resetCursor = function (index) {
15975
+
15976
+
if (typeof index === 'undefined') { index = 0; }
15977
+
15978
+
if (index > this.children.length - 1)
15979
+
{
15980
+
index = 0;
15981
+
}
15982
+
15983
+
if (this.cursor)
15984
+
{
15985
+
this._cache[8] = index;
15986
+
this.cursor = this.children[this._cache[8]];
15987
+
return this.cursor;
15988
+
}
15989
+
15990
+
};
15991
+
15967
15992
/**
15968
15993
* Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
if (operation === 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
16263
16286
else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
@@ -17001,7 +17024,8 @@ Phaser.Group.prototype.getRandom = function (startIndex, length) {
17001
17024
};
17002
17025
17003
17026
/**
17004
-
* Removes the given child from this Group and sets its group property to null.
17027
+
* Removes the given child from this Group. This will dispatch an onRemovedFromGroup event from the child (if it has one),
17028
+
* reset the Group cursor and optionally destroy the child.
17005
17029
*
17006
17030
* @method Phaser.Group#remove
17007
17031
* @param {Any} child - The child to remove.
@@ -17012,7 +17036,7 @@ Phaser.Group.prototype.remove = function (child, destroy) {
17012
17036
17013
17037
if (typeof destroy === 'undefined') { destroy = false; }
17014
17038
17015
-
if (this.children.length === 0)
17039
+
if (this.children.length === 0 || this.children.indexOf(child) === -1)
17016
17040
{
17017
17041
return false;
17018
17042
}
@@ -17033,7 +17057,7 @@ Phaser.Group.prototype.remove = function (child, destroy) {
17033
17057
17034
17058
if (destroy && removed)
17035
17059
{
17036
-
removed.destroy();
17060
+
removed.destroy(true);
17037
17061
}
17038
17062
17039
17063
return true;
@@ -17067,7 +17091,7 @@ Phaser.Group.prototype.removeAll = function (destroy) {
17067
17091
17068
17092
if (destroy && removed)
17069
17093
{
17070
-
removed.destroy();
17094
+
removed.destroy(true);
17071
17095
}
17072
17096
}
17073
17097
while (this.children.length > 0);
@@ -17112,7 +17136,7 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy)
17112
17136
17113
17137
if (destroy && removed)
17114
17138
{
17115
-
removed.destroy();
17139
+
removed.destroy(true);
17116
17140
}
17117
17141
17118
17142
if (this.cursor === this.children[i])
@@ -17147,10 +17171,12 @@ Phaser.Group.prototype.destroy = function (destroyChildren, soft) {
17147
17171
17148
17172
if (!soft)
17149
17173
{
17150
-
this.parent.removeChild(this);
17174
+
if (this.parent)
17175
+
{
17176
+
this.parent.removeChild(this);
17177
+
}
17151
17178
17152
17179
this.game = null;
17153
-
17154
17180
this.exists = false;
17155
17181
}
17156
17182
@@ -17374,6 +17400,65 @@ Phaser.World.prototype.shutdown = function () {
17374
17400
17375
17401
};
17376
17402
17403
+
/**
17404
+
* This will take the given game object and check if its x/y coordinates fall outside of the world bounds.
17405
+
* If they do it will reposition the object to the opposite side of the world, creating a wrap-around effect.
17406
+
*
17407
+
* @method Phaser.World#wrap
17408
+
* @param {Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Text} sprite - The object you wish to wrap around the world bounds.
17409
+
* @param {number} [padding=0] - Extra padding added equally to the sprite.x and y coordinates before checking if within the world bounds. Ignored if useBounds is true.
17410
+
* @param {boolean} [useBounds=false] - If useBounds is false wrap checks the object.x/y coordinates. If true it does a more accurate bounds check, which is more expensive.
17411
+
*/
17412
+
Phaser.World.prototype.wrap = function (sprite, padding, useBounds) {
17413
+
17414
+
if (typeof padding === 'undefined') { padding = 0; }
17415
+
if (typeof useBounds === 'undefined') { useBounds = false; }
17416
+
17417
+
if (!useBounds)
17418
+
{
17419
+
if (sprite.x + padding < this.bounds.x)
17420
+
{
17421
+
sprite.x = this.bounds.right + padding;
17422
+
}
17423
+
else if (sprite.x - padding > this.bounds.right)
17424
+
{
17425
+
sprite.x = this.bounds.left - padding;
17426
+
}
17427
+
17428
+
if (sprite.y + padding < this.bounds.top)
17429
+
{
17430
+
sprite.y = this.bounds.bottom + padding;
17431
+
}
17432
+
else if (sprite.y - padding > this.bounds.bottom)
17433
+
{
17434
+
sprite.y = this.bounds.top - padding;
17435
+
}
17436
+
}
17437
+
else
17438
+
{
17439
+
sprite.getBounds();
17440
+
17441
+
if (sprite._currentBounds.right < this.bounds.x)
17442
+
{
17443
+
sprite.x = this.bounds.right;
17444
+
}
17445
+
else if (sprite._currentBounds.x > this.bounds.right)
17446
+
{
17447
+
sprite.x = this.bounds.left;
17448
+
}
17449
+
17450
+
if (sprite._currentBounds.bottom < this.bounds.top)
17451
+
{
17452
+
sprite.y = this.bounds.bottom;
17453
+
}
17454
+
else if (sprite._currentBounds.top > this.bounds.bottom)
17455
+
{
17456
+
sprite.y = this.bounds.top;
17457
+
}
17458
+
}
17459
+
17460
+
};
17461
+
17377
17462
/**
17378
17463
* @name Phaser.World#width
17379
17464
* @property {number} width - Gets or sets the current width of the game world.
@@ -23700,7 +23785,10 @@ Phaser.InputHandler = function (sprite) {
23700
23785
this.enabled = false;
23701
23786
23702
23787
/**
23703
-
* @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
23788
+
* The priorityID is used to determine which game objects should get priority when input events occur. For example if you have
23789
+
* several Sprites that overlap, by default the one at the top of the display list is given priority for input events. You can
23790
+
* stop this from happening by controlling the priorityID value. The higher the value, the more important they are considered to the Input events.
23791
+
* @property {number} priorityID
23704
23792
* @default
23705
23793
*/
23706
23794
this.priorityID = 0;
@@ -34039,15 +34127,15 @@ Phaser.Math = {
34039
34127
},
34040
34128
34041
34129
/**
34042
-
* Keeps an angle value between -180 and +180<br>
34043
-
* Should be called whenever the angle is updated on the Sprite to stop it from going insane.
34130
+
* Keeps an angle value between -180 and +180.
34044
34131
*
34045
34132
* @method Phaser.Math#wrapAngle
34046
34133
* @param {number} angle - The angle value to check
34047
-
* @param {boolean} radians - True if angle sizes are expressed in radians.
34134
+
* @param {boolean} radians - True if angle is given in radians.
34048
34135
* @return {number} The new angle value, returns the same as the input angle if it was within bounds.
0 commit comments