|
13 | 13 | * In addition, Groups provides support for fast pooling and object recycling. |
14 | 14 | * |
15 | 15 | * Groups are also display objects and can be nested as children within other Groups. |
16 | | -* |
| 16 | +* |
17 | 17 | * @class Phaser.Group |
18 | 18 | * @extends PIXI.DisplayObjectContainer |
19 | 19 | * @param {Phaser.Game} game - A reference to the currently running game. |
@@ -107,13 +107,13 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody |
107 | 107 | this.ignoreDestroy = false; |
108 | 108 |
|
109 | 109 | /** |
110 | | - * A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method |
| 110 | + * A Group is that has `pendingDestroy` set to `true` is flagged to have its destroy method |
111 | 111 | * called on the next logic update. |
112 | 112 | * You can set it directly to flag the Group to be destroyed on its next update. |
113 | | - * |
114 | | - * This is extremely useful if you wish to destroy a Group from within one of its own callbacks |
| 113 | + * |
| 114 | + * This is extremely useful if you wish to destroy a Group from within one of its own callbacks |
115 | 115 | * or a callback of one of its children. |
116 | | - * |
| 116 | + * |
117 | 117 | * @property {boolean} pendingDestroy |
118 | 118 | */ |
119 | 119 | this.pendingDestroy = false; |
@@ -164,7 +164,7 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody |
164 | 164 |
|
165 | 165 | /** |
166 | 166 | * If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property. |
167 | | - * |
| 167 | + * |
168 | 168 | * It should be set to one of the Phaser.Physics.Arcade sort direction constants: |
169 | 169 | * |
170 | 170 | * Phaser.Physics.Arcade.SORT_NONE |
@@ -1976,57 +1976,60 @@ Phaser.Group.prototype.getBottom = function () { |
1976 | 1976 | }; |
1977 | 1977 |
|
1978 | 1978 | /** |
1979 | | -* Get the closest child to given Object/Point/Sprite/Image |
1980 | | -* |
1981 | | -* @method Phaser.Group#getClosestTo |
1982 | | -* @return {any} The child closest to given Object/Point/Sprite/Image |
1983 | | -*/ |
1984 | | -Phaser.Group.prototype.getClosestTo = function (object) { |
1985 | | - |
1986 | | - if (this.children.length !== 0) { |
1987 | | - var distance = Number.MAX_VALUE, |
1988 | | - tempDistance = 0, |
1989 | | - returnee; |
1990 | | - this.forEachAlive(function(e) { |
1991 | | - |
1992 | | - tempDistance = Math.abs(Phaser.Point.distance(object, e)); |
1993 | | - |
1994 | | - if (tempDistance < distance) { |
1995 | | - distance = tempDistance; |
1996 | | - returnee = e; |
1997 | | - } |
1998 | | - }); |
1999 | | - |
2000 | | - if (returnee) return returnee; |
2001 | | - } |
2002 | | - |
2003 | | -}; |
2004 | | - |
2005 | | -/** |
2006 | | -* Get the farthest child to given Object/Point/Sprite/Image |
2007 | | -* |
2008 | | -* @method Phaser.Group#getFarthestFrom |
2009 | | -* @return {any} The child farthest from given Object/Point/Sprite/Image |
2010 | | -*/ |
2011 | | -Phaser.Group.prototype.getFarthestFrom = function (object) { |
2012 | | - |
2013 | | - if (this.children.length !== 0) { |
2014 | | - var distance = 0, |
2015 | | - tempDistance = 0, |
2016 | | - returnee; |
2017 | | - this.forEachAlive(function(e) { |
2018 | | - |
2019 | | - tempDistance = Math.abs(Phaser.Point.distance(object, e)); |
2020 | | - |
2021 | | - if (tempDistance > distance) { |
2022 | | - distance = tempDistance; |
2023 | | - returnee = e; |
2024 | | - } |
2025 | | - }); |
2026 | | - |
2027 | | - if (returnee) return returnee; |
2028 | | - } |
2029 | | - |
| 1979 | + * Get the closest child to given Object/Point/Sprite/Image |
| 1980 | + * |
| 1981 | + * @method Phaser.Group#getClosestTo |
| 1982 | + * @return {any} The child closest to given Object/Point/Sprite/Image |
| 1983 | + */ |
| 1984 | +Phaser.Group.prototype.getClosestTo = function(object) { |
| 1985 | + |
| 1986 | + if (this.children.length !== 0) { |
| 1987 | + var distance = Number.MAX_VALUE, |
| 1988 | + tempDistance = 0, |
| 1989 | + returnee; |
| 1990 | + this.forEachAlive(function(e) { |
| 1991 | + |
| 1992 | + tempDistance = Math.abs(Phaser.Point.distance(object, e)); |
| 1993 | + |
| 1994 | + if (tempDistance < distance) { |
| 1995 | + distance = tempDistance; |
| 1996 | + returnee = e; |
| 1997 | + } |
| 1998 | + }); |
| 1999 | + |
| 2000 | + if (returnee) { |
| 2001 | + return returnee |
| 2002 | + }; |
| 2003 | + } |
| 2004 | + |
| 2005 | +}; |
| 2006 | + |
| 2007 | +/** |
| 2008 | + * Get the farthest child from given Object/Point/Sprite/Image |
| 2009 | + * |
| 2010 | + * @method Phaser.Group#getFarthestFrom |
| 2011 | + * @return {any} The child farthest from given Object/Point/Sprite/Image |
| 2012 | + */ |
| 2013 | +Phaser.Group.prototype.getFarthestFrom = function(object) { |
| 2014 | + |
| 2015 | + if (this.children.length !== 0) { |
| 2016 | + var distance = 0, |
| 2017 | + tempDistance = 0, |
| 2018 | + returnee; |
| 2019 | + this.forEachAlive(function(e) { |
| 2020 | + |
| 2021 | + tempDistance = Math.abs(Phaser.Point.distance(object, e)); |
| 2022 | + |
| 2023 | + if (tempDistance > distance) { |
| 2024 | + distance = tempDistance; |
| 2025 | + returnee = e; |
| 2026 | + } |
| 2027 | + }); |
| 2028 | + if (returnee) { |
| 2029 | + return returnee |
| 2030 | + }; |
| 2031 | + } |
| 2032 | + |
2030 | 2033 | }; |
2031 | 2034 |
|
2032 | 2035 | /** |
|
0 commit comments