Skip to main content
Version: Phaser v4.0.0

Group

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

Groups are commonly used to implement object pools, where a fixed set of Game Objects are created up front and then recycled by toggling their active and visible states, avoiding the overhead of repeated construction and garbage collection. This pattern is especially useful for frequently spawned objects such as bullets, particles, or enemies.

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.

Constructor

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

Parameters

nametypeoptionaldescription
scenePhaser.SceneNoThe scene this group belongs to.
childrenArray.<Phaser.GameObjects.GameObject> | Phaser.Types.GameObjects.Group.GroupConfigPhaser.Types.GameObjects.Group.GroupCreateConfigYes
configPhaser.Types.GameObjects.Group.GroupConfig | Phaser.Types.GameObjects.Group.GroupCreateConfigYesSettings for this group. If key is set, Phaser.GameObjects.Group#createMultiple is also called with these settings.

Scope: static

Extends

Phaser.Events.EventEmitter

Source: src/gameobjects/group/Group.js#L19
Since: 3.0.0

Public Members

active

active: boolean

Description:

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

Source: src/gameobjects/group/Group.js#L153
Since: 3.0.0


children

children: Set.<Phaser.GameObjects.GameObject>

Description:

Members of this group.

Source: src/gameobjects/group/Group.js#L99
Since: 3.0.0


classType

classType: function

Description:

The class to create new group members from.

The constructor arguments must match (scene, x, y, texture, frame).

Source: src/gameobjects/group/Group.js#L129
Since: 3.0.0


createCallback

createCallback: Phaser.Types.GameObjects.Group.GroupCallback

Description:

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

Source: src/gameobjects/group/Group.js#L204
Since: 3.0.0


createMultipleCallback

createMultipleCallback: Phaser.Types.GameObjects.Group.GroupMultipleCreateCallback

Description:

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

Source: src/gameobjects/group/Group.js#L222
Since: 3.0.0


defaultFrame

defaultFrame: string, number

Description:

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

Source: src/gameobjects/group/Group.js#L184
Since: 3.0.0


defaultKey

defaultKey: string

Description:

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.

Source: src/gameobjects/group/Group.js#L172
Since: 3.0.0


isParent

isParent: boolean

Description:

A flag identifying this object as a group.

Source: src/gameobjects/group/Group.js#L108
Since: 3.0.0


maxSize

maxSize: number

Description:

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

Source: src/gameobjects/group/Group.js#L162
Since: 3.0.0


name

name: string

Description:

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

Source: src/gameobjects/group/Group.js#L142
Since: 3.18.0


removeCallback

removeCallback: Phaser.Types.GameObjects.Group.GroupCallback

Description:

A function to be called when removing group members.

Source: src/gameobjects/group/Group.js#L213
Since: 3.0.0


runChildUpdate

runChildUpdate: boolean

Description:

Whether to call the update method of any members.

Source: src/gameobjects/group/Group.js#L193
Since: 3.0.0


scene

scene: Phaser.Scene

Description:

This scene this group belongs to.

Source: src/gameobjects/group/Group.js#L90
Since: 3.0.0


type

type: string

Description:

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

Source: src/gameobjects/group/Group.js#L118
Since: 3.21.0


Inherited Methods

From Phaser.Events.EventEmitter:


Public Methods

add

<instance> add(child, [addToScene])

Description:

Adds a Game Object to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

nametypeoptionaldefaultdescription
childPhaser.GameObjects.GameObjectNoThe Game Object to add.
addToScenebooleanYesfalseAlso add the Game Object to the scene.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L588
Since: 3.0.0


addedToScene

<instance> addedToScene()

Description:

Called when this Group is added to a Scene. Registers this Group with the Scene's update list so that its preUpdate method is called each game step.

Source: src/gameobjects/group/Group.js#L267
Since: 3.0.0


addMultiple

<instance> addMultiple(children, [addToScene])

Description:

Adds several Game Objects to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

nametypeoptionaldefaultdescription
childrenArray.<Phaser.GameObjects.GameObject>NoThe Game Objects to add.
addToScenebooleanYesfalseAlso add the Game Objects to the scene.

Returns: Phaser.GameObjects.Group - This group.

Source: src/gameobjects/group/Group.js#L633
Since: 3.0.0


angle

<instance> angle(value, [step])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to add to the angle, in degrees.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1403
Since: 3.21.0


clear

<instance> clear([removeFromScene], [destroyChild])

Description:

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:

nametypeoptionaldefaultdescription
removeFromScenebooleanYesfalseOptionally remove each Group member from the Scene.
destroyChildbooleanYesfalseOptionally call destroy on the removed Group members.

Returns: Phaser.GameObjects.Group - This group.

Source: src/gameobjects/group/Group.js#L712
Since: 3.0.0


contains

<instance> contains(child)

Description:

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

Parameters:

nametypeoptionaldescription
childPhaser.GameObjects.GameObjectNoA Game Object.

Returns: boolean - True if the Game Object is a member of this group.

Source: src/gameobjects/group/Group.js#L752
Since: 3.0.0


countActive

<instance> countActive([value])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
valuebooleanYestrueCount active (true) or inactive (false) group members.

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

Source: src/gameobjects/group/Group.js#L1133
Since: 3.0.0


create

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

Description:

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

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

nametypeoptionaldefaultdescription
xnumberYes0The horizontal position of the new Game Object in the world.
ynumberYes0The vertical position of the new Game Object in the world.
keystringYes"defaultKey"The texture key of the new Game Object.
framestring | numberYes"defaultFrame"The texture frame of the new Game Object.
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object.
activebooleanYestrueThe {@link Phaser.GameObjects.GameObject#active} state of the new Game Object.

Returns: any - The new Game Object (usually a Sprite, etc.).

Source: src/gameobjects/group/Group.js#L291
Since: 3.0.0


createFromConfig

<instance> createFromConfig(options)

Description:

A helper for Phaser.GameObjects.Group#createMultiple.

Parameters:

nametypeoptionaldescription
optionsPhaser.Types.GameObjects.Group.GroupCreateConfigNoCreation settings.

Returns: Array.<any> - The newly created Game Objects.

Source: src/gameobjects/group/Group.js#L377
Since: 3.0.0


createMultiple

<instance> createMultiple(config)

Description:

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:

nametypeoptionaldescription
configPhaser.Types.GameObjects.Group.GroupCreateConfig | Array.<Phaser.Types.GameObjects.Group.GroupCreateConfig>NoCreation settings. This can be a single configuration object or an array of such objects, which will be applied in turn.

Returns: Array.<any> - The newly created Game Objects.

Source: src/gameobjects/group/Group.js#L336
Since: 3.0.0


destroy

<instance> destroy([destroyChildren], [removeFromScene])

Description:

Empties this Group of all children and removes it from the Scene.

Does not call Phaser.GameObjects.Group#removeCallback.

Children of this Group will not be removed from the Scene by calling this method unless you specify the removeFromScene parameter.

Children of this Group will also not be destroyed by calling this method unless you specify the destroyChildren parameter.

Parameters:

nametypeoptionaldefaultdescription
destroyChildrenbooleanYesfalseAlso {@link Phaser.GameObjects.GameObject#destroy} each Group member.
removeFromScenebooleanYesfalseOptionally remove each Group member from the Scene.

Overrides: Phaser.Events.EventEmitter#destroy

Source: src/gameobjects/group/Group.js#L1725
Since: 3.0.0


get

<instance> get([x], [y], [key], [frame], [visible])

Description:

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:

nametypeoptionaldefaultdescription
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The first inactive group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L1022
Since: 3.0.0


getChildren

<instance> getChildren()

Description:

All members of the group.

Returns: Array.<Phaser.GameObjects.GameObject> - The group members.

Source: src/gameobjects/group/Group.js#L767
Since: 3.0.0


getFirst

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

Description:

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:

nametypeoptionaldefaultdescription
statebooleanYesfalseThe {@link Phaser.GameObjects.GameObject#active} value to match.
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The first matching group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L817
Since: 3.0.0


getFirstAlive

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

Description:

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:

nametypeoptionaldefaultdescription
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The first active group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L1046
Since: 3.0.0


getFirstDead

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

Description:

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:

nametypeoptionaldefaultdescription
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The first inactive group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L1070
Since: 3.0.0


getFirstNth

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

Description:

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:

nametypeoptionaldefaultdescription
nthnumberNoThe nth matching Group member to search for.
statebooleanYesfalseThe {@link Phaser.GameObjects.GameObject#active} value to match.
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The nth matching group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L842
Since: 3.6.0


getLast

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

Description:

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:

nametypeoptionaldefaultdescription
statebooleanYesfalseThe {@link Phaser.GameObjects.GameObject#active} value to match.
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The last matching group member, or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L868
Since: 3.6.0


getLastNth

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

Description:

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:

nametypeoptionaldefaultdescription
nthnumberNoThe nth matching Group member to search for.
statebooleanYesfalseThe {@link Phaser.GameObjects.GameObject#active} value to match.
createIfNullbooleanYesfalseCreate a new Game Object if no matching members are found, using the following arguments.
xnumberYesThe horizontal position of the Game Object in the world.
ynumberYesThe vertical position of the Game Object in the world.
keystringYes"defaultKey"The texture key assigned to a new Game Object (if one is created).
framestring | numberYes"defaultFrame"A texture frame assigned to a new Game Object (if one is created).
visiblebooleanYestrueThe {@link Phaser.GameObjects.Components.Visible#visible} state of a new Game Object (if one is created).

Returns: any - The nth matching group member (searching from the end), or a newly created member, or null.

Source: src/gameobjects/group/Group.js#L893
Since: 3.6.0


getLength

<instance> getLength()

Description:

The number of members of the group.

Returns: number - The total number of members in this Group.

Source: src/gameobjects/group/Group.js#L780
Since: 3.0.0


getMatching

<instance> getMatching([property], [value], [startIndex], [endIndex])

Description:

Returns all children in this Group that match the given criteria based on the property and value arguments.

For example: getMatching('visible', true) would return only children that have their visible property set.

Optionally, you can specify a start and end index. For example if the Group has 100 elements, and you set startIndex to 0 and endIndex to 50, it would return matches from only the first 50.

Parameters:

nametypeoptionaldescription
propertystringYesThe property to test on each array element.
value*YesThe value to test the property against. Must pass a strict (===) comparison check.
startIndexnumberYesAn optional start index to search from.
endIndexnumberYesAn optional end index to search to.

Returns: Array.<any> - An array of matching Group members. The array will be empty if nothing matched.

Source: src/gameobjects/group/Group.js#L793
Since: 3.50.0


getTotalFree

<instance> getTotalFree()

Description:

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.

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

Source: src/gameobjects/group/Group.js#L1173
Since: 3.0.0


getTotalUsed

<instance> getTotalUsed()

Description:

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

Returns: number - The number of group members with an active state of true.

Source: src/gameobjects/group/Group.js#L1160
Since: 3.0.0


incX

<instance> incX(value, [step])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to be added to the x property.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1325
Since: 3.21.0


incXY

<instance> incXY(x, [y], [stepX], [stepY])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe amount to be added to the x property.
ynumberYes"x"The amount to be added to the y property. If undefined or null it uses the x value.
stepXnumberYes0This is added to the x amount, multiplied by the iteration counter.
stepYnumberYes0This is added to the y amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1361
Since: 3.21.0


incY

<instance> incY(value, [step])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to be added to the y property.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1343
Since: 3.21.0


isFull

<instance> isFull()

Description:

Whether this group's size is at its maximum.

Returns: boolean - True if the number of members equals Phaser.GameObjects.Group#maxSize.

Source: src/gameobjects/group/Group.js#L1113
Since: 3.0.0


kill

<instance> kill(gameObject)

Description:

Deactivates a member of this group.

Parameters:

nametypeoptionaldescription
gameObjectPhaser.GameObjects.GameObjectNoA member of this group.

Source: src/gameobjects/group/Group.js#L1658
Since: 3.0.0


killAndHide

<instance> killAndHide(gameObject)

Description:

Deactivates and hides a member of this group.

Parameters:

nametypeoptionaldescription
gameObjectPhaser.GameObjects.GameObjectNoA member of this group.

Source: src/gameobjects/group/Group.js#L1674
Since: 3.0.0


playAnimation

<instance> playAnimation(key, [startFrame])

Description:

Plays an animation for all members of this group.

Parameters:

nametypeoptionaldefaultdescription
keystringNoThe string-based key of the animation to play.
startFramestringYes0Optionally start the animation playing from this frame index.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1095
Since: 3.0.0


preUpdate

<instance> preUpdate(time, delta)

Description:

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

Parameters:

nametypeoptionaldescription
timenumberNoThe current timestamp.
deltanumberNoThe delta time elapsed since the last frame.

Source: src/gameobjects/group/Group.js#L563
Since: 3.0.0


propertyValueInc

<instance> propertyValueInc(key, value, [step], [index], [direction])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
keystringNoThe property to be updated.
valuenumberNoThe amount to add to the property.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.
indexnumberYes0An optional offset to start searching from within the items array.
directionnumberYes1The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1248
Since: 3.21.0


propertyValueSet

<instance> propertyValueSet(key, value, [step], [index], [direction])

Description:

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

Parameters:

nametypeoptionaldefaultdescription
keystringNoThe property to be updated.
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.
indexnumberYes0An optional offset to start searching from within the items array.
directionnumberYes1The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1227
Since: 3.21.0


remove

<instance> remove(child, [removeFromScene], [destroyChild])

Description:

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

Calls Phaser.GameObjects.Group#removeCallback.

Parameters:

nametypeoptionaldefaultdescription
childPhaser.GameObjects.GameObjectNoThe Game Object to remove.
removeFromScenebooleanYesfalseOptionally remove the Group member from the Scene it belongs to.
destroyChildbooleanYesfalseOptionally call destroy on the removed Group member.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L661
Since: 3.0.0


removedFromScene

<instance> removedFromScene()

Description:

Called when this Group is removed from a Scene. Unregisters this Group from the Scene's update list so that its preUpdate method is no longer called each game step.

Source: src/gameobjects/group/Group.js#L279
Since: 3.0.0


rotate

<instance> rotate(value, [step])

Description:

Sets the rotation of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the rotation to, in radians.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1421
Since: 3.21.0


rotateAround

<instance> rotateAround(point, angle)

Description:

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

Parameters:

nametypeoptionaldescription
pointPhaser.Types.Math.Vector2LikeNoAny object with public x and y properties.
anglenumberNoThe angle to rotate by, in radians.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1439
Since: 3.21.0


rotateAroundDistance

<instance> rotateAroundDistance(point, angle, distance)

Description:

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

Parameters:

nametypeoptionaldescription
pointPhaser.Types.Math.Vector2LikeNoAny object with public x and y properties.
anglenumberNoThe angle to rotate by, in radians.
distancenumberNoThe distance from the point of rotation in pixels.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1457
Since: 3.21.0


scaleX

<instance> scaleX(value, [step])

Description:

Sets the scaleX of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1534
Since: 3.21.0


scaleXY

<instance> scaleXY(scaleX, [scaleY], [stepX], [stepY])

Description:

Sets the scaleX, scaleY of each group member.

Parameters:

nametypeoptionaldefaultdescription
scaleXnumberNoThe amount to set the scaleX property to.
scaleYnumberYesThe amount to set the scaleY property to. If undefined or null it uses the scaleX value.
stepXnumberYes0This is added to the scaleX amount, multiplied by the iteration counter.
stepYnumberYes0This is added to the scaleY amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1570
Since: 3.21.0


scaleY

<instance> scaleY(value, [step])

Description:

Sets the scaleY of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1552
Since: 3.21.0


setActive

<instance> setActive(value)

Description:

Sets the active property of this Group. When active, this Group runs its preUpdate method.

Parameters:

nametypeoptionaldescription
valuebooleanNoTrue if this Group should be set as active, false if not.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1191
Since: 3.24.0


setAlpha

<instance> setAlpha(value, [step])

Description:

Sets the alpha of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the alpha to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1476
Since: 3.21.0


setBlendMode

<instance> setBlendMode(value)

Description:

Sets the blendMode of each group member.

Parameters:

nametypeoptionaldescription
valuenumberNoThe blend mode value to set. See Phaser.BlendModes for valid values.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1608
Since: 3.21.0


setDepth

<instance> setDepth(value, [step])

Description:

Sets the depth of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1590
Since: 3.0.0


setHitArea

<instance> setHitArea(hitArea, hitAreaCallback)

Description:

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

Parameters:

nametypeoptionaldescription
hitArea*NoEither 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.
hitAreaCallbackPhaser.Types.Input.HitAreaCallbackNoA callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1625
Since: 3.21.0


setName

<instance> setName(value)

Description:

Sets the name property of this Group. The name property is not populated by Phaser and is presented for your own use.

Parameters:

nametypeoptionaldescription
valuestringNoThe name to be given to this Group.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1209
Since: 3.24.0


setOrigin

<instance> setOrigin(originX, [originY], [stepX], [stepY])

Description:

Sets the originX, originY of each group member.

Parameters:

nametypeoptionaldefaultdescription
originXnumberNoThe amount to set the originX property to.
originYnumberYesThe amount to set the originY property to. If undefined or null it uses the originX value.
stepXnumberYes0This is added to the originX amount, multiplied by the iteration counter.
stepYnumberYes0This is added to the originY amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1514
Since: 3.21.0


setTint

<instance> setTint(topLeft, [topRight], [bottomLeft], [bottomRight])

Description:

Sets the tint of each group member.

Parameters:

nametypeoptionaldescription
topLeftnumberNoThe tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item.
topRightnumberYesThe tint to be applied to top-right corner of item.
bottomLeftnumberYesThe tint to be applied to the bottom-left corner of item.
bottomRightnumberYesThe tint to be applied to the bottom-right corner of item.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1494
Since: 3.21.0


setVisible

<instance> setVisible(value, [index], [direction])

Description:

Sets the visibility of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuebooleanNoThe value to set the property to.
indexnumberYes0An optional offset to start searching from within the items array.
directionnumberYes1The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1691
Since: 3.21.0


setX

<instance> setX(value, [step])

Description:

Sets the x of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1269
Since: 3.21.0


setXY

<instance> setXY(x, [y], [stepX], [stepY])

Description:

Sets the x, y of each group member.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe amount to set the x property to.
ynumberYes"x"The amount to set the y property to. If undefined or null it uses the x value.
stepXnumberYes0This is added to the x amount, multiplied by the iteration counter.
stepYnumberYes0This is added to the y amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1305
Since: 3.21.0


setY

<instance> setY(value, [step])

Description:

Sets the y of each group member.

Parameters:

nametypeoptionaldefaultdescription
valuenumberNoThe amount to set the property to.
stepnumberYes0This is added to the value amount, multiplied by the iteration counter.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1287
Since: 3.21.0


shiftPosition

<instance> shiftPosition(x, y, [direction])

Description:

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:

nametypeoptionaldefaultdescription
xnumberNoThe x coordinate to place the first item in the array at.
ynumberNoThe y coordinate to place the first item in the array at.
directionnumberYes0The iteration direction. 0 = first to last and 1 = last to first.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1381
Since: 3.21.0


shuffle

<instance> shuffle()

Description:

Shuffles the group members in place.

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1643
Since: 3.21.0


toggleVisible

<instance> toggleVisible()

Description:

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

Returns: Phaser.GameObjects.Group - This Group object.

Source: src/gameobjects/group/Group.js#L1710
Since: 3.0.0