Improve RenderFilters.Replace static function.

This commit is contained in:
Ben Richards 2024-11-21 16:35:23 +13:00
parent db76e501f1
commit 0a0aa0281d

View file

@ -860,8 +860,10 @@ var RenderFilters = new Class({
* @since 4.0.0 * @since 4.0.0
* @static * @static
* @param {Phaser.GameObjects.GameObject} child - The Game Object that is being wrapped by this RenderFilters instance. * @param {Phaser.GameObjects.GameObject} child - The Game Object that is being wrapped by this RenderFilters instance.
* @param {boolean} [autoFocus=false] - Whether the RenderFilters should automatically focus on the child every frame. Sets `autoFocus` property.
* @param {boolean} [autoTransfer=false] - Whether the RenderFilters should automatically transfer properties from the child to itself every frame. Sets `autoTransferProperties` property. If not set, it defaults to the `autoFocus` param.
*/ */
RenderFilters.Replace = function (child) RenderFilters.Replace = function (child, autoFocus, autoTransfer)
{ {
var scene = child.scene; var scene = child.scene;
if (!scene) if (!scene)
@ -876,7 +878,7 @@ RenderFilters.Replace = function (child)
} }
var index = child.displayList.getIndex(child); var index = child.displayList.getIndex(child);
var renderFilters = new RenderFilters(scene, child); var renderFilters = new RenderFilters(scene, child, autoFocus, autoTransfer);
scene.sys.displayList.addAt(renderFilters, index); scene.sys.displayList.addAt(renderFilters, index);
return renderFilters; return renderFilters;