mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Group.bringToTop (and consequently Sprite.bringToTop) no longer removes the child from the InputManager if enabled (thanks @BinaryMoon, fix #928)
Group.sendToBack (and consequently Sprite.sendToBack) no longer removes the child from the InputManager if enabled. Group.add has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event. Group.addAt has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event. Group.remove has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onRemovedFromGroup` event. Group.removeBetween has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events. Group.removeAll has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events. Internal child movements in Group (such as bringToTop) now uses the new `silent` parameter to avoid the child emitting incorrect Group addition and deletion events.
This commit is contained in:
parent
2cef655ed6
commit
2916f0413f
3 changed files with 41 additions and 21 deletions
|
@ -115,6 +115,12 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Full Mouse Wheel support added, with new constants and callbacks for mouse wheel movement (thanks @woutercommandeur, #959)
|
||||
* A Phaser version of the Pixi PixelateFilter was added by @paperkettle #939)
|
||||
* TileMap.setPreventRecalculate allows you to turn on / off the recalculation of tile faces for tile collision, which is handy when modifying large portions of a map to avoid slow-down (thanks @sivael, #951)
|
||||
* Group.add has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event.
|
||||
* Group.addAt has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onAddedToGroup` event.
|
||||
* Group.remove has a new optional boolean parameter: `silent`. If set to `true` the child will not dispatch its `onRemovedFromGroup` event.
|
||||
* Group.removeBetween has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
|
||||
* Group.removeAll has a new optional boolean parameter: `silent`. If set to `true` the children will not dispatch their `onRemovedFromGroup` events.
|
||||
* Internal child movements in Group (such as bringToTop) now uses the new `silent` parameter to avoid the child emitting incorrect Group addition and deletion events.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
@ -148,6 +154,8 @@ Calling addToWorld() would previously not check the _toRemove array, which could
|
|||
* Device.mobileSafari was no longer detecting Mobile Safari, now fixed (thanks @Zammy, #927)
|
||||
* Rectangle.right when set would set the new width to be Rectangle.x + the value given. However the value given should be a new Right coordinate, so the width calculation has been adjusted to compensate (thanks @cryptonomicon, #849)
|
||||
* Calling Tween.stop from inside a Tween update callback would still cause the tween onComplete event to fire (thanks @eguneys, #924)
|
||||
* Group.bringToTop (and consequently Sprite.bringToTop) no longer removes the child from the InputManager if enabled (thanks @BinaryMoon, fix #928)
|
||||
* Group.sendToBack (and consequently Sprite.sendToBack) no longer removes the child from the InputManager if enabled.
|
||||
|
||||
|
||||
### ToDo
|
||||
|
|
10
build/phaser.d.ts
vendored
10
build/phaser.d.ts
vendored
|
@ -2253,10 +2253,10 @@ declare module Phaser {
|
|||
type: number;
|
||||
z: number;
|
||||
|
||||
add(child: any): any;
|
||||
add(child: any, silent?: boolean): any;
|
||||
addAll(property: string, amount: number, checkAlive: boolean, checkVisible: boolean): void;
|
||||
addAt(child: any, index: number, silent?: boolean): any;
|
||||
bringToTop(child: any): any;
|
||||
addAt(child: any, index: number): any;
|
||||
callAll(method: string, context: any, ...parameters: any[]): void;
|
||||
callAllExists(callback: Function, existsValue: boolean, ...parameters: any[]): void;
|
||||
callbackFromArray(child: Object, callback: Function, length: number): void;
|
||||
|
@ -2288,9 +2288,9 @@ declare module Phaser {
|
|||
postUpdate(): void;
|
||||
preUpdate(): void;
|
||||
previous(): void;
|
||||
remove(child: any, destroy?: boolean): boolean;
|
||||
removeAll(destroy?: boolean): void;
|
||||
removeBetween(startIndex: number, endIndex?: number, destroy?: boolean): void;
|
||||
remove(child: any, destroy?: boolean, silent?: boolean): boolean;
|
||||
removeAll(destroy?: boolean, silent?: boolean): void;
|
||||
removeBetween(startIndex: number, endIndex?: number, destroy?: boolean, silent?: boolean): void;
|
||||
replace(oldChild: any, newChild: any): any;
|
||||
reverse(): void;
|
||||
sendToBack(child: any): any;
|
||||
|
|
|
@ -190,9 +190,12 @@ Phaser.Group.SORT_DESCENDING = 1;
|
|||
* @see Phaser.Group#addAt
|
||||
* @method Phaser.Group#add
|
||||
* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
|
||||
* @param {boolean} [silent=false] - If the silent parameter is `true` the child will not dispatch the onAddedToGroup event.
|
||||
* @return {*} The child that was added to the Group.
|
||||
*/
|
||||
Phaser.Group.prototype.add = function (child) {
|
||||
Phaser.Group.prototype.add = function (child, silent) {
|
||||
|
||||
if (typeof silent === 'undefined') { silent = false; }
|
||||
|
||||
if (child.parent !== this)
|
||||
{
|
||||
|
@ -205,7 +208,7 @@ Phaser.Group.prototype.add = function (child) {
|
|||
|
||||
child.z = this.children.length;
|
||||
|
||||
if (child.events)
|
||||
if (!silent && child.events)
|
||||
{
|
||||
child.events.onAddedToGroup.dispatch(child, this);
|
||||
}
|
||||
|
@ -227,9 +230,12 @@ Phaser.Group.prototype.add = function (child) {
|
|||
* @method Phaser.Group#addAt
|
||||
* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
|
||||
* @param {number} index - The index within the Group to insert the child to.
|
||||
* @param {boolean} [silent=false] - If the silent parameter is `true` the child will not dispatch the onAddedToGroup event.
|
||||
* @return {*} The child that was added to the Group.
|
||||
*/
|
||||
Phaser.Group.prototype.addAt = function (child, index) {
|
||||
Phaser.Group.prototype.addAt = function (child, index, silent) {
|
||||
|
||||
if (typeof silent === 'undefined') { silent = false; }
|
||||
|
||||
if (child.parent !== this)
|
||||
{
|
||||
|
@ -242,7 +248,7 @@ Phaser.Group.prototype.addAt = function (child, index) {
|
|||
|
||||
this.updateZ();
|
||||
|
||||
if (child.events)
|
||||
if (!silent && child.events)
|
||||
{
|
||||
child.events.onAddedToGroup.dispatch(child, this);
|
||||
}
|
||||
|
@ -473,8 +479,8 @@ Phaser.Group.prototype.bringToTop = function (child) {
|
|||
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
this.remove(child, false, true);
|
||||
this.add(child, true);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -492,8 +498,8 @@ Phaser.Group.prototype.sendToBack = function (child) {
|
|||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
this.remove(child, false, true);
|
||||
this.addAt(child, 0, true);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -1486,18 +1492,20 @@ Phaser.Group.prototype.getRandom = function (startIndex, length) {
|
|||
* @method Phaser.Group#remove
|
||||
* @param {Any} child - The child to remove.
|
||||
* @param {boolean} [destroy=false] - You can optionally call destroy on the child that was removed.
|
||||
* @param {boolean} [silent=false] - If the silent parameter is `true` the child will not dispatch the onRemovedFromGroup event.
|
||||
* @return {boolean} true if the child was removed from this Group, otherwise false.
|
||||
*/
|
||||
Phaser.Group.prototype.remove = function (child, destroy) {
|
||||
Phaser.Group.prototype.remove = function (child, destroy, silent) {
|
||||
|
||||
if (typeof destroy === 'undefined') { destroy = false; }
|
||||
if (typeof silent === 'undefined') { silent = false; }
|
||||
|
||||
if (this.children.length === 0 || this.children.indexOf(child) === -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child.events && !child.destroyPhase)
|
||||
if (!silent && child.events && !child.destroyPhase)
|
||||
{
|
||||
child.events.onRemovedFromGroup.dispatch(child, this);
|
||||
}
|
||||
|
@ -1521,15 +1529,17 @@ Phaser.Group.prototype.remove = function (child, destroy) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Removes all children from this Group, setting all group properties to null.
|
||||
* Removes all children from this Group, setting the group properties of the children to `null`.
|
||||
* The Group container remains on the display list.
|
||||
*
|
||||
* @method Phaser.Group#removeAll
|
||||
* @param {boolean} [destroy=false] - You can optionally call destroy on the child that was removed.
|
||||
* @param {boolean} [destroy=false] - You can optionally call destroy on each child that is removed.
|
||||
* @param {boolean} [silent=false] - If the silent parameter is `true` the children will not dispatch their onRemovedFromGroup events.
|
||||
*/
|
||||
Phaser.Group.prototype.removeAll = function (destroy) {
|
||||
Phaser.Group.prototype.removeAll = function (destroy, silent) {
|
||||
|
||||
if (typeof destroy === 'undefined') { destroy = false; }
|
||||
if (typeof silent === 'undefined') { silent = false; }
|
||||
|
||||
if (this.children.length === 0)
|
||||
{
|
||||
|
@ -1538,7 +1548,7 @@ Phaser.Group.prototype.removeAll = function (destroy) {
|
|||
|
||||
do
|
||||
{
|
||||
if (this.children[0].events)
|
||||
if (!silent && this.children[0].events)
|
||||
{
|
||||
this.children[0].events.onRemovedFromGroup.dispatch(this.children[0], this);
|
||||
}
|
||||
|
@ -1563,11 +1573,13 @@ Phaser.Group.prototype.removeAll = function (destroy) {
|
|||
* @param {number} startIndex - The index to start removing children from.
|
||||
* @param {number} [endIndex] - The index to stop removing children at. Must be higher than startIndex. If undefined this method will remove all children between startIndex and the end of the Group.
|
||||
* @param {boolean} [destroy=false] - You can optionally call destroy on the child that was removed.
|
||||
* @param {boolean} [silent=false] - If the silent parameter is `true` the children will not dispatch their onRemovedFromGroup events.
|
||||
*/
|
||||
Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy) {
|
||||
Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy, silent) {
|
||||
|
||||
if (typeof endIndex === 'undefined') { endIndex = this.children.length; }
|
||||
if (typeof destroy === 'undefined') { destroy = false; }
|
||||
if (typeof silent === 'undefined') { silent = false; }
|
||||
|
||||
if (this.children.length === 0)
|
||||
{
|
||||
|
@ -1583,7 +1595,7 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex, destroy)
|
|||
|
||||
while (i >= startIndex)
|
||||
{
|
||||
if (this.children[i].events)
|
||||
if (!silent && this.children[i].events)
|
||||
{
|
||||
this.children[i].events.onRemovedFromGroup.dispatch(this.children[i], this);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue