Class: Group

Phaser.GameObjects. Group

A Group is a way for you to create, manipulate, or recycle similar Game Objects.

Group membership is non-exclusive. A Game Object can belong to several groups, one group, or none.

Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden.


new Group(scene [, children] [, config])

Parameters:
Name Type Argument Description
scene Phaser.Scene

The scene this group belongs to.

children Array.<Phaser.GameObjects.GameObject> | Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

Game Objects to add to this group; or the config argument.

config Phaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfig <optional>

Settings for this group. If key is set, Phaser.GameObjects.Group#createMultiple is also called with these settings.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 17)
See:

Members


active :boolean

Whether this group runs its Phaser.GameObjects.Group#preUpdate method (which may update any members).

Type:
  • boolean
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 138)

children :Phaser.Structs.Set.<Phaser.GameObjects.GameObject>

Members of this group.

Type:
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 87)

classType :function

The class to create new group members from.

Type:
  • function
Since: 3.0.0
Default Value:
  • Phaser.GameObjects.Sprite
Source: src/gameobjects/group/Group.js (Line 117)

<nullable> createCallback :Phaser.Types.GameObjects.Group.GroupCallback

A function to be called when adding or creating group members.

Type:
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 190)

<nullable> createMultipleCallback :Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback

A function to be called when creating several group members at once.

Type:
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 208)

defaultFrame :string|integer

A default texture frame to use when creating new group members.

Type:
  • string | integer
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 170)

defaultKey :string

A default texture key to use when creating new group members.

This is used in Phaser.GameObjects.Group#create but not in Phaser.GameObjects.Group#createMultiple.

Type:
  • string
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 158)

isParent :boolean

A flag identifying this object as a group.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/gameobjects/group/Group.js (Line 96)

maxSize :integer

The maximum size of this group, if used as a pool. -1 is no limit.

Type:
  • integer
Since: 3.0.0
Default Value:
  • -1
Source: src/gameobjects/group/Group.js (Line 148)

name :string

The name of this group. Empty by default and never populated by Phaser, this is left for developers to use.

Type:
  • string
Since: 3.18.0
Default Value:
  • ''
Source: src/gameobjects/group/Group.js (Line 127)

<nullable> removeCallback :Phaser.Types.GameObjects.Group.GroupCallback

A function to be called when removing group members.

Type:
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 199)

runChildUpdate :boolean

Whether to call the update method of any members.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/gameobjects/group/Group.js (Line 179)
See:

scene :Phaser.Scene

This scene this group belongs to.

Type:
Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 78)

type :string

A textual representation of this Game Object. Used internally by Phaser but is available for your own custom classes to populate.

Type:
  • string
Since: 3.21.0
Default Value:
  • 'Group'
Source: src/gameobjects/group/Group.js (Line 106)

Methods


add(child [, addToScene])

Adds a Game Object to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:
Name Type Argument Default Description
child Phaser.GameObjects.GameObject

The Game Object to add.

addToScene boolean <optional>
false

Also add the Game Object to the scene.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 513)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

addMultiple(children [, addToScene])

Adds several Game Objects to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:
Name Type Argument Default Description
children Array.<Phaser.GameObjects.GameObject>

The Game Objects to add.

addToScene boolean <optional>
false

Also add the Game Objects to the scene.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 562)
Returns:

This group.

Type
Phaser.GameObjects.Group

angle(value [, step])

Sets the angle of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the angle to, in degrees.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1282)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

clear( [removeFromScene] [, destroyChild])

Removes all members of this Group and optionally removes them from the Scene and / or destroys them.

Does not call Phaser.GameObjects.Group#removeCallback.

Parameters:
Name Type Argument Default Description
removeFromScene boolean <optional>
false

Optionally remove each Group member from the Scene.

destroyChild boolean <optional>
false

Optionally call destroy on the removed Group members.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 645)
Returns:

This group.

Type
Phaser.GameObjects.Group

contains(child)

Tests if a Game Object is a member of this group.

Parameters:
Name Type Description
child Phaser.GameObjects.GameObject

A Game Object.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 691)
Returns:

True if the Game Object is a member of this group.

Type
boolean

countActive( [value])

Counts the number of active (or inactive) group members.

Parameters:
Name Type Argument Default Description
value boolean <optional>
true

Count active (true) or inactive (false) group members.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1048)
Returns:

The number of group members with an active state matching the active argument.

Type
integer

create( [x] [, y] [, key] [, frame] [, visible] [, active])

Creates a new Game Object and adds it to this group, unless the group is full.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:
Name Type Argument Default Description
x number <optional>
0

The horizontal position of the new Game Object in the world.

y number <optional>
0

The vertical position of the new Game Object in the world.

key string <optional>
defaultKey

The texture key of the new Game Object.

frame string | integer <optional>
defaultFrame

The texture frame of the new Game Object.

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of the new Game Object.

active boolean <optional>
true

The Phaser.GameObjects.GameObject#active state of the new Game Object.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 245)
Returns:

The new Game Object (usually a Sprite, etc.).

Type
any

createFromConfig(options)

Parameters:
Name Type Description
options Phaser.Types.GameObjects.Group.GroupCreateConfig

Creation settings.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 335)
Returns:

The newly created Game Objects.

Type
Array.<any>

createMultiple(config)

Creates several Game Objects and adds them to this group.

If the group becomes Phaser.GameObjects.Group#isFull, no further Game Objects are created.

Calls Phaser.GameObjects.Group#createMultipleCallback and Phaser.GameObjects.Group#createCallback.

Parameters:
Name Type Description
config Phaser.Types.GameObjects.Group.GroupCreateConfig | Array.<Phaser.Types.GameObjects.Group.GroupCreateConfig>

Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 294)
Returns:

The newly created Game Objects.

Type
Array.<any>

destroy( [destroyChildren])

Empties this group and removes it from the Scene.

Does not call Phaser.GameObjects.Group#removeCallback.

Parameters:
Name Type Argument Default Description
destroyChildren boolean <optional>
false

Also Phaser.GameObjects.GameObject#destroy each group member.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1604)

get( [x] [, y] [, key] [, frame] [, visible])

Scans the group for the first member that has an Phaser.GameObjects.GameObject#active state set to false, assigns x and y, and returns the member.

If no inactive member is found and the group isn't full then it will create a new Game Object using x, y, key, frame, and visible. The new Game Object will have its active state set to true. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 937)
Returns:

The first inactive group member, or a newly created member, or null.

Type
any

getChildren()

All members of the group.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 706)
Returns:

The group members.

Type
Array.<Phaser.GameObjects.GameObject>

getFirst( [state] [, createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the Group, from top to bottom, for the first member that has an Phaser.GameObjects.GameObject#active state matching the argument, assigns x and y, and returns the member.

If no matching member is found and createIfNull is true and the group isn't full then it will create a new Game Object using x, y, key, frame, and visible. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
state boolean <optional>
false

The Phaser.GameObjects.GameObject#active value to match.

createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 732)
Returns:

The first matching group member, or a newly created member, or null.

Type
any

getFirstAlive( [createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the group for the first member that has an Phaser.GameObjects.GameObject#active state set to true, assigns x and y, and returns the member.

If no active member is found and createIfNull is true and the group isn't full then it will create a new one using x, y, key, frame, and visible. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 961)
Returns:

The first active group member, or a newly created member, or null.

Type
any

getFirstDead( [createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the group for the first member that has an Phaser.GameObjects.GameObject#active state set to false, assigns x and y, and returns the member.

If no inactive member is found and createIfNull is true and the group isn't full then it will create a new one using x, y, key, frame, and visible. The new Game Object will have an active state set to true. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 985)
Returns:

The first inactive group member, or a newly created member, or null.

Type
any

getFirstNth(nth [, state] [, createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the Group, from top to bottom, for the nth member that has an Phaser.GameObjects.GameObject#active state matching the argument, assigns x and y, and returns the member.

If no matching member is found and createIfNull is true and the group isn't full then it will create a new Game Object using x, y, key, frame, and visible. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
nth integer

The nth matching Group member to search for.

state boolean <optional>
false

The Phaser.GameObjects.GameObject#active value to match.

createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.6.0
Source: src/gameobjects/group/Group.js (Line 757)
Returns:

The first matching group member, or a newly created member, or null.

Type
any

getLast( [state] [, createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the Group for the last member that has an Phaser.GameObjects.GameObject#active state matching the argument, assigns x and y, and returns the member.

If no matching member is found and createIfNull is true and the group isn't full then it will create a new Game Object using x, y, key, frame, and visible. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
state boolean <optional>
false

The Phaser.GameObjects.GameObject#active value to match.

createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.6.0
Source: src/gameobjects/group/Group.js (Line 783)
Returns:

The first matching group member, or a newly created member, or null.

Type
any

getLastNth(nth [, state] [, createIfNull] [, x] [, y] [, key] [, frame] [, visible])

Scans the Group for the last nth member that has an Phaser.GameObjects.GameObject#active state matching the argument, assigns x and y, and returns the member.

If no matching member is found and createIfNull is true and the group isn't full then it will create a new Game Object using x, y, key, frame, and visible. Unless a new member is created, key, frame, and visible are ignored.

Parameters:
Name Type Argument Default Description
nth integer

The nth matching Group member to search for.

state boolean <optional>
false

The Phaser.GameObjects.GameObject#active value to match.

createIfNull boolean <optional>
false

Create a new Game Object if no matching members are found, using the following arguments.

x number <optional>

The horizontal position of the Game Object in the world.

y number <optional>

The vertical position of the Game Object in the world.

key string <optional>
defaultKey

The texture key assigned to a new Game Object (if one is created).

frame string | integer <optional>
defaultFrame

A texture frame assigned to a new Game Object (if one is created).

visible boolean <optional>
true

The Phaser.GameObjects.Components.Visible#visible state of a new Game Object (if one is created).

Since: 3.6.0
Source: src/gameobjects/group/Group.js (Line 808)
Returns:

The first matching group member, or a newly created member, or null.

Type
any

getLength()

The number of members of the group.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 719)
Returns:
Type
integer

getTotalFree()

The difference of Phaser.GameObjects.Group#maxSize and the number of active group members.

This represents the number of group members that could be created or reactivated before reaching the size limit.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1088)
Returns:

maxSize minus the number of active group numbers; or a large number (if maxSize is -1).

Type
integer

getTotalUsed()

Counts the number of in-use (active) group members.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1075)
Returns:

The number of group members with an active state of true.

Type
integer

incX(value [, step])

Adds the given value to the x of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to be added to the x property.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1204)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

incXY(x [, y] [, stepX] [, stepY])

Adds the given value to the x, y of each group member.

Parameters:
Name Type Argument Default Description
x number

The amount to be added to the x property.

y number <optional>
x

The amount to be added to the y property. If undefined or null it uses the x value.

stepX number <optional>
0

This is added to the x amount, multiplied by the iteration counter.

stepY number <optional>
0

This is added to the y amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1240)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

incY(value [, step])

Adds the given value to the y of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to be added to the y property.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1222)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

isFull()

Whether this group's size at its maximum.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1028)
Returns:

True if the number of members equals Phaser.GameObjects.Group#maxSize.

Type
boolean

kill(gameObject)

Deactivates a member of this group.

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

A member of this group.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1537)

killAndHide(gameObject)

Deactivates and hides a member of this group.

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

A member of this group.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1553)

playAnimation(key [, startFrame])

Plays an animation for all members of this group.

Parameters:
Name Type Argument Default Description
key string

The string-based key of the animation to play.

startFrame string <optional>
0

Optionally start the animation playing from this frame index.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1010)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

preUpdate(time, delta)

Updates any group members, if Phaser.GameObjects.Group#runChildUpdate is enabled.

Parameters:
Name Type Description
time number

The current timestamp.

delta number

The delta time elapsed since the last frame.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 483)

propertyValueInc(key, value [, step] [, index] [, direction])

Adds the given value to the property as defined in key of each group member.

Parameters:
Name Type Argument Default Description
key string

The property to be updated.

value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

index integer <optional>
0

An optional offset to start searching from within the items array.

direction integer <optional>
1

The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1127)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

propertyValueSet(key, value [, step] [, index] [, direction])

Sets the property as defined in key of each group member to the given value.

Parameters:
Name Type Argument Default Description
key string

The property to be updated.

value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

index integer <optional>
0

An optional offset to start searching from within the items array.

direction integer <optional>
1

The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1106)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

remove(child [, removeFromScene] [, destroyChild])

Removes a member of this Group and optionally removes it from the Scene and / or destroys it.

Calls Phaser.GameObjects.Group#removeCallback.

Parameters:
Name Type Argument Default Description
child Phaser.GameObjects.GameObject

The Game Object to remove.

removeFromScene boolean <optional>
false

Optionally remove the Group member from the Scene it belongs to.

destroyChild boolean <optional>
false

Optionally call destroy on the removed Group member.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 590)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

rotate(value [, step])

Sets the rotation of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the rotation to, in radians.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1300)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

rotateAround(point, angle)

Rotates each group member around the given point by the given angle.

Parameters:
Name Type Description
point Phaser.Types.Math.Vector2Like

Any object with public x and y properties.

angle number

The angle to rotate by, in radians.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1318)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

rotateAroundDistance(point, angle, distance)

Rotates each group member around the given point by the given angle and distance.

Parameters:
Name Type Description
point Phaser.Types.Math.Vector2Like

Any object with public x and y properties.

angle number

The angle to rotate by, in radians.

distance number

The distance from the point of rotation in pixels.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1336)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

scaleX(value [, step])

Sets the scaleX of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1413)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

scaleXY(scaleX [, scaleY] [, stepX] [, stepY])

Sets the scaleX, scaleY of each group member.

Parameters:
Name Type Argument Default Description
scaleX number

The amount to be added to the scaleX property.

scaleY number <optional>

The amount to be added to the scaleY property. If undefined or null it uses the scaleX value.

stepX number <optional>
0

This is added to the scaleX amount, multiplied by the iteration counter.

stepY number <optional>
0

This is added to the scaleY amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1449)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

scaleY(value [, step])

Sets the scaleY of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1431)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setAlpha(value [, step])

Sets the alpha of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the alpha to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1355)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setBlendMode(value)

Sets the blendMode of each group member.

Parameters:
Name Type Description
value number

The amount to set the property to.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1487)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setDepth(value [, step])

Sets the depth of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1469)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setHitArea(hitArea, hitAreaCallback)

Passes all group members to the Input Manager to enable them for input with identical areas and callbacks.

Parameters:
Name Type Description
hitArea *

Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.

hitAreaCallback Phaser.Types.Input.HitAreaCallback

A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1504)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setOrigin(originX [, originY] [, stepX] [, stepY])

Sets the originX, originY of each group member.

Parameters:
Name Type Argument Default Description
originX number

The amount to set the originX property to.

originY number <optional>

The amount to set the originY property to. If undefined or null it uses the originX value.

stepX number <optional>
0

This is added to the originX amount, multiplied by the iteration counter.

stepY number <optional>
0

This is added to the originY amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1393)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setTint(topLeft [, topRight] [, bottomLeft] [, bottomRight])

Sets the tint of each group member.

Parameters:
Name Type Argument Description
topLeft number

The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item.

topRight number <optional>

The tint to be applied to top-right corner of item.

bottomLeft number <optional>

The tint to be applied to the bottom-left corner of item.

bottomRight number <optional>

The tint to be applied to the bottom-right corner of item.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1373)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setVisible(value [, index] [, direction])

Sets the visible of each group member.

Parameters:
Name Type Argument Default Description
value boolean

The value to set the property to.

index integer <optional>
0

An optional offset to start searching from within the items array.

direction integer <optional>
1

The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1570)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setX(value [, step])

Sets the x of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1148)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setXY(x [, y] [, stepX] [, stepY])

Sets the x, y of each group member.

Parameters:
Name Type Argument Default Description
x number

The amount to set the x property to.

y number <optional>
x

The amount to set the y property to. If undefined or null it uses the x value.

stepX number <optional>
0

This is added to the x amount, multiplied by the iteration counter.

stepY number <optional>
0

This is added to the y amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1184)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

setY(value [, step])

Sets the y of each group member.

Parameters:
Name Type Argument Default Description
value number

The amount to set the property to.

step number <optional>
0

This is added to the value amount, multiplied by the iteration counter.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1166)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

shiftPosition(x, y [, direction])

Iterate through the group members changing the position of each element to be that of the element that came before it in the array (or after it if direction = 1)

The first group member position is set to x/y.

Parameters:
Name Type Argument Default Description
x number

The x coordinate to place the first item in the array at.

y number

The y coordinate to place the first item in the array at.

direction integer <optional>
0

The iteration direction. 0 = first to last and 1 = last to first.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1260)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

shuffle()

Shuffles the group members in place.

Since: 3.21.0
Source: src/gameobjects/group/Group.js (Line 1522)
Returns:

This Group object.

Type
Phaser.GameObjects.Group

toggleVisible()

Toggles (flips) the visible state of each member of this group.

Since: 3.0.0
Source: src/gameobjects/group/Group.js (Line 1589)
Returns:

This Group object.

Type
Phaser.GameObjects.Group