From b12f3bbaa004feaf9f0983091d1af61b55973fbb Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 5 Sep 2024 11:29:29 +0100 Subject: [PATCH] Renamed methods to avoid Container conflicts --- src/gameobjects/components/Depth.js | 92 ++++++++++------------------- 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/src/gameobjects/components/Depth.js b/src/gameobjects/components/Depth.js index 08982fb1cb..aad1cfc859 100644 --- a/src/gameobjects/components/Depth.js +++ b/src/gameobjects/components/Depth.js @@ -89,27 +89,20 @@ var Depth = { }, /** - * Bring this Game Object to the top of the display list, or the top of its parent container. + * Sets this Game Object to be at the top of the display list, or the top of its parent container. * * Being at the top means it will render on-top of everything else. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. * - * @method Phaser.GameObjects.Components.Depth#bringToTop + * @method Phaser.GameObjects.Components.Depth#setToTop * @since 3.85.0 * * @return {this} This Game Object instance. */ - bringToTop: function () + setToTop: function () { - var list; - - if (this.parentContainer) - { - list = this.parentContainer.list; - } - else if (this.displayList) - { - list = this.displayList.list; - } + var list = this.getDisplayList(); if (list) { @@ -120,27 +113,20 @@ var Depth = { }, /** - * Send this Game Object to the back of the display list, or the back of its parent container. + * Sets this Game Object to the back of the display list, or the back of its parent container. * * Being at the back means it will render below everything else. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. * - * @method Phaser.GameObjects.Components.Depth#sendToBack + * @method Phaser.GameObjects.Components.Depth#setToBack * @since 3.85.0 * * @return {this} This Game Object instance. */ - sendToBack: function () + setToBack: function () { - var list; - - if (this.parentContainer) - { - list = this.parentContainer.list; - } - else if (this.displayList) - { - list = this.displayList.list; - } + var list = this.getDisplayList(); if (list) { @@ -151,70 +137,56 @@ var Depth = { }, /** - * Move this Game Object so that it appears below the given Game Object. + * Move this Game Object so that it appears above the given Game Object. * - * This means it will render immediately under the other object in the display list. + * This means it will render immediately after the other object in the display list. * * Both objects must belong to the same display list, or parent container. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. * - * @method Phaser.GameObjects.Components.Depth#moveBelow + * @method Phaser.GameObjects.Components.Depth#setAbove * @since 3.85.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be below. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be above. * * @return {this} This Game Object instance. */ - moveBelow: function (gameObject) + setAbove: function (gameObject) { - var list; - - if (this.parentContainer) - { - list = this.parentContainer.list; - } - else if (this.displayList) - { - list = this.displayList.list; - } + var list = this.getDisplayList(); - if (list && gameObject && this !== gameObject) + if (list && gameObject) { - ArrayUtils.MoveBelow(list, this, gameObject); + ArrayUtils.MoveAbove(list, this, gameObject); } return this; }, /** - * Move this Game Object so that it appears above the given Game Object. + * Move this Game Object so that it appears below the given Game Object. * - * This means it will render immediately after the other object in the display list. + * This means it will render immediately under the other object in the display list. * * Both objects must belong to the same display list, or parent container. + * + * This method does not change this Game Objects `depth` value, it simply alters its list position. * - * @method Phaser.GameObjects.Components.Depth#moveAbove + * @method Phaser.GameObjects.Components.Depth#setBelow * @since 3.85.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be above. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that this Game Object will be moved to be below. * * @return {this} This Game Object instance. */ - moveAbove: function (gameObject) + setBelow: function (gameObject) { - var list; - - if (this.parentContainer) - { - list = this.parentContainer.list; - } - else if (this.displayList) - { - list = this.displayList.list; - } + var list = this.getDisplayList(); - if (list && gameObject && this !== gameObject) + if (list && gameObject) { - ArrayUtils.MoveAbove(list, this, gameObject); + ArrayUtils.MoveBelow(list, this, gameObject); } return this;