From 7f41624869ad97653c1fb44901d76e71162bb60d Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 14 Mar 2026 14:27:40 -0700 Subject: [PATCH] Add x, y options in group create multiple --- src/gameobjects/group/Group.js | 13 ++++++++++--- src/gameobjects/group/typedefs/GroupCreateConfig.js | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gameobjects/group/Group.js b/src/gameobjects/group/Group.js index 6a0e7ef7f1..f90a259bb4 100644 --- a/src/gameobjects/group/Group.js +++ b/src/gameobjects/group/Group.js @@ -8,6 +8,7 @@ var Actions = require('../../actions/'); var Class = require('../../utils/Class'); var Events = require('../events'); var EventEmitter = require('eventemitter3'); +var GetAdvancedValue = require('../../utils/object/GetAdvancedValue'); var GetAll = require('../../utils/array/GetAll'); var GetFastValue = require('../../utils/object/GetFastValue'); var GetValue = require('../../utils/object/GetValue'); @@ -442,9 +443,15 @@ var Group = new Class({ this.internalRemoveCallback = options.internalRemoveCallback; } + var x; + var y; + for (var c = 0; c < range.length; c++) { - var created = this.create(0, 0, range[c].a, range[c].b, visible, active); + x = GetAdvancedValue(options, 'x', 0); + y = GetAdvancedValue(options, 'y', 0); + + var created = this.create(x, y, range[c].a, range[c].b, visible, active); if (!created) { @@ -458,8 +465,8 @@ var Group = new Class({ if (HasValue(options, 'setXY')) { - var x = GetValue(options, 'setXY.x', 0); - var y = GetValue(options, 'setXY.y', 0); + x = GetValue(options, 'setXY.x', 0); + y = GetValue(options, 'setXY.y', 0); var stepX = GetValue(options, 'setXY.stepX', 0); var stepY = GetValue(options, 'setXY.stepY', 0); diff --git a/src/gameobjects/group/typedefs/GroupCreateConfig.js b/src/gameobjects/group/typedefs/GroupCreateConfig.js index b3cdffa88f..4aa3ea2a02 100644 --- a/src/gameobjects/group/typedefs/GroupCreateConfig.js +++ b/src/gameobjects/group/typedefs/GroupCreateConfig.js @@ -22,6 +22,8 @@ * @property {?boolean} [yoyo=false] - Select keys and frames by moving forward then backward through `key` and `frame`. * @property {?number} [frameQuantity=1] - The number of times each `frame` should be combined with one `key`. * @property {?number} [max=0] - The maximum number of new Game Objects to create. 0 is no maximum. + * @property {?(number|number[]|object)} [x=0] - The horizontal position of each new Game Object. See value types in {@link Phaser.Utils.Objects.GetAdvancedValue}. + * @property {?(number|number[]|object)} [y=0] - The vertical position of each new Game Object. See value types in {@link Phaser.Utils.Objects.GetAdvancedValue}. * @property {?object} [setXY] * @property {?number} [setXY.x=0] - The horizontal position of each new Game Object. * @property {?number} [setXY.y=0] - The vertical position of each new Game Object.