Phaser API Documentation

  Version: 
Filter

An Arcade Physics Static Group object.

All Game Objects created by or added to this Group will automatically be given static Arcade Physics bodies, if they have no body.

Its dynamic counterpart is Phaser.Physics.Arcade.Group.

Constructor:

new StaticGroup(world, scene, [children], [config])

Parameters:

name type arguments description
world Phaser.Physics.Arcade.World

The physics simulation.

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.

Since: 3.0.0

Extends


Members

active: boolean
Focus
Focus

Description:

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

Type:
boolean
Inherited from: Phaser.GameObjects.Group#active
Since: 3.0.0
Focus
Focus
classType: function
Focus
Focus

Description:

The class to create new group members from.

Type:
function
Default: Phaser.GameObjects.Sprite
Inherited from: Phaser.GameObjects.Group#classType
Since: 3.0.0
Focus
Focus

Description:

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

Type:
Inherited from: Phaser.GameObjects.Group#createCallback
Since: 3.0.0
Focus
Focus

Description:

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

Type:
Inherited from: Phaser.GameObjects.Group#createMultipleCallback
Since: 3.0.0
Focus
Focus
defaultFrame: string | number
Focus
Focus

Description:

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

Type:
string | number
Inherited from: Phaser.GameObjects.Group#defaultFrame
Since: 3.0.0
Focus
Focus
defaultKey: string
Focus
Focus

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.

Type:
string
Inherited from: Phaser.GameObjects.Group#defaultKey
Since: 3.0.0
Focus
Focus
<private, nullable> internalCreateCallback: Phaser.Types.GameObjects.Group.GroupCallback
Focus
Focus

Description:

A function to be called when adding or creating group members. For internal use only by a Group, or any class that extends it.

Type:
Inherited from: Phaser.GameObjects.Group#internalCreateCallback
Since: 3.22.0
Focus
Focus
<private, nullable> internalRemoveCallback: Phaser.Types.GameObjects.Group.GroupCallback
Focus
Focus

Description:

A function to be called when removing group members. For internal use only by a Group, or any class that extends it.

Type:
Inherited from: Phaser.GameObjects.Group#internalRemoveCallback
Since: 3.22.0
Focus
Focus
isParent: boolean
Focus
Focus

Description:

A flag identifying this object as a group.

Type:
boolean
Default: true
Inherited from: Phaser.GameObjects.Group#isParent
Since: 3.0.0
Focus
Focus
maxSize: number
Focus
Focus

Description:

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

Type:
number
Default: -1
Inherited from: Phaser.GameObjects.Group#maxSize
Since: 3.0.0
Focus
Focus
name: string
Focus
Focus

Description:

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

Type:
string
Default: ''
Inherited from: Phaser.GameObjects.Group#name
Since: 3.18.0
Focus
Focus
physicsType: number
Focus
Focus

Description:

The scene this group belongs to.

Type:
number
Default: Phaser.Physics.Arcade.STATIC_BODY
Since: 3.0.0
Focus
Focus

Description:

A function to be called when removing group members.

Type:
Inherited from: Phaser.GameObjects.Group#removeCallback
Since: 3.0.0
Focus
Focus
runChildUpdate: boolean
Focus
Focus

Description:

Whether to call the update method of any members.

Type:
boolean
Default: false
Inherited from: Phaser.GameObjects.Group#runChildUpdate
Since: 3.0.0
Focus
Focus
scene: Phaser.Scene
Focus
Focus

Description:

This scene this group belongs to.

Type:
Inherited from: Phaser.GameObjects.Group#scene
Since: 3.0.0
Focus
Focus
type: string
Focus
Focus

Description:

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

Type:
string
Default: 'StaticPhysicsGroup'
Overrides: Phaser.GameObjects.Group#type
Since: 3.21.0
Focus
Focus

Description:

The physics simulation.

Type:
Since: 3.0.0
Focus
Focus

Methods

add(child, [addToScene])
Focus
Focus

Description:

Adds a Game Object to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

name type arguments Default description
child Phaser.GameObjects.GameObject

The Game Object to add.

addToScene boolean <optional> false

Also add the Game Object to the scene.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#add
Since: 3.0.0
Focus
Focus
addListener(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#addListener
Since: 3.0.0
Focus
Focus
addMultiple(children, [addToScene])
Focus
Focus

Description:

Adds several Game Objects to this group.

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

name type arguments Default description
children Array.<Phaser.GameObjects.GameObject>

The Game Objects to add.

addToScene boolean <optional> false

Also add the Game Objects to the scene.

Returns:
Description:

This group.

Inherited from: Phaser.GameObjects.Group#addMultiple
Since: 3.0.0
Focus
Focus
angle(value, [step])
Focus
Focus

Description:

Sets the angle of each group member.

Parameters:

name type arguments description
value number

The amount to set the angle to, in degrees.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#angle
Since: 3.21.0
Focus
Focus
clear([removeFromScene], [destroyChild])
Focus
Focus

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:

name type arguments 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.

Returns:
Description:

This group.

Inherited from: Phaser.GameObjects.Group#clear
Since: 3.0.0
Focus
Focus
contains(child)
Focus
Focus

Description:

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

Parameters:

name type description
child Phaser.GameObjects.GameObject

A Game Object.

Returns:
Description:

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

Type:
  • boolean
Inherited from: Phaser.GameObjects.Group#contains
Since: 3.0.0
Focus
Focus
countActive([value])
Focus
Focus

Description:

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

Parameters:

name type arguments Default description
value boolean <optional> true

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

Returns:
Description:

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

Type:
  • number
Inherited from: Phaser.GameObjects.Group#countActive
Since: 3.0.0
Focus
Focus
create([x], [y], [key], [frame], [visible], [active])
Focus
Focus

Description:

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

Calls Phaser.GameObjects.Group#createCallback.

Parameters:

name type arguments 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 | number <optional> defaultFrame

The texture frame of the new Game Object.

visible boolean <optional> true

The {@link Phaser.GameObjects.Components.Visible#visible} state of the new Game Object.

active boolean <optional> true

The {@link Phaser.GameObjects.GameObject#active} state of the new Game Object.

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#create
Since: 3.0.0
Focus
Focus
createCallbackHandler(child)
Focus
Focus

Description:

Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation.

Parameters:

name type description
child Phaser.GameObjects.GameObject

The new group member.

Since: 3.0.0
Focus
Focus
createFromConfig(options)
Focus
Focus

Description:

A helper for Phaser.GameObjects.Group#createMultiple.

Parameters:

name type description
options Phaser.Types.GameObjects.Group.GroupCreateConfig

Creation settings.

Returns:
Description:

The newly created Game Objects.

Type:
  • Array.
Inherited from: Phaser.GameObjects.Group#createFromConfig
Since: 3.0.0
Focus
Focus
createMultiple(config)
Focus
Focus

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:

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.

Returns:
Description:

The newly created Game Objects.

Type:
  • Array.
Inherited from: Phaser.GameObjects.Group#createMultiple
Since: 3.0.0
Focus
Focus
createMultipleCallbackHandler(entries)
Focus
Focus

Description:

Refreshes the group.

Parameters:

name type description
entries Array.<Phaser.GameObjects.GameObject>

The newly created group members.

Since: 3.0.0
Focus
Focus
destroy([destroyChildren], [removeFromScene])
Focus
Focus

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:

name type arguments Default description
destroyChildren boolean <optional> false

Also {@link Phaser.GameObjects.GameObject#destroy} each Group member.

removeFromScene boolean <optional> false

Optionally remove each Group member from the Scene.

Inherited from: Phaser.GameObjects.Group#destroy
Since: 3.0.0
Focus
Focus
emit(event, [args])
Focus
Focus

Description:

Calls each of the listeners registered for a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

args * <optional>

Additional arguments that will be passed to the event handler.

Returns:
Description:

true if the event had listeners, else false.

Type:
  • boolean
Inherited from: Phaser.Events.EventEmitter#emit
Since: 3.0.0
Focus
Focus
eventNames()
Focus
Focus

Description:

Return an array listing the events for which the emitter has registered listeners.

Type:
  • Array.<(string
  • symbol)>
Inherited from: Phaser.Events.EventEmitter#eventNames
Since: 3.0.0
Focus
Focus
get([x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#get
Since: 3.0.0
Focus
Focus
getChildren()
Focus
Focus

Description:

All members of the group.

Returns:
Description:

The group members.

Inherited from: Phaser.GameObjects.Group#getChildren
Since: 3.0.0
Focus
Focus
getFirst([state], [createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments Default description
state boolean <optional> false

The {@link 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getFirst
Since: 3.0.0
Focus
Focus
getFirstAlive([createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getFirstAlive
Since: 3.0.0
Focus
Focus
getFirstDead([createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getFirstDead
Since: 3.0.0
Focus
Focus
getFirstNth(nth, [state], [createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments Default description
nth number

The nth matching Group member to search for.

state boolean <optional> false

The {@link 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getFirstNth
Since: 3.6.0
Focus
Focus
<private> getHandler(forwards, nth, [state], [createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments Default description
forwards boolean

Search front to back or back to front?

nth number

Stop matching after nth successful matches.

state boolean <optional> false

The {@link 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getHandler
Since: 3.6.0
Focus
Focus
getLast([state], [createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments Default description
state boolean <optional> false

The {@link 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getLast
Since: 3.6.0
Focus
Focus
getLastNth(nth, [state], [createIfNull], [x], [y], [key], [frame], [visible])
Focus
Focus

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:

name type arguments Default description
nth number

The nth matching Group member to search for.

state boolean <optional> false

The {@link 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 | number <optional> defaultFrame

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

visible boolean <optional> true

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

Returns:
Description:

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

Type:
  • any
Inherited from: Phaser.GameObjects.Group#getLastNth
Since: 3.6.0
Focus
Focus
getLength()
Focus
Focus

Description:

The number of members of the group.

Type:
  • number
Inherited from: Phaser.GameObjects.Group#getLength
Since: 3.0.0
Focus
Focus
getMatching([property], [value], [startIndex], [endIndex])
Focus
Focus

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:

name type arguments description
property string <optional>

The property to test on each array element.

value * <optional>

The value to test the property against. Must pass a strict (===) comparison check.

startIndex number <optional>

An optional start index to search from.

endIndex number <optional>

An optional end index to search to.

Returns:
Description:

An array of matching Group members. The array will be empty if nothing matched.

Type:
  • Array.
Inherited from: Phaser.GameObjects.Group#getMatching
Since: 3.50.0
Focus
Focus
getTotalFree()
Focus
Focus

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:
Description:

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

Type:
  • number
Inherited from: Phaser.GameObjects.Group#getTotalFree
Since: 3.0.0
Focus
Focus
getTotalUsed()
Focus
Focus

Description:

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

Returns:
Description:

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

Type:
  • number
Inherited from: Phaser.GameObjects.Group#getTotalUsed
Since: 3.0.0
Focus
Focus
incX(value, [step])
Focus
Focus

Description:

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

Parameters:

name type arguments description
value number

The amount to be added to the x property.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#incX
Since: 3.21.0
Focus
Focus
incXY(x, [y], [stepX], [stepY])
Focus
Focus

Description:

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

Parameters:

name type arguments 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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#incXY
Since: 3.21.0
Focus
Focus
incY(value, [step])
Focus
Focus

Description:

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

Parameters:

name type arguments description
value number

The amount to be added to the y property.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#incY
Since: 3.21.0
Focus
Focus
isFull()
Focus
Focus

Description:

Whether this group's size at its maximum.

Returns:
Description:

True if the number of members equals {@link Phaser.GameObjects.Group#maxSize}.

Type:
  • boolean
Inherited from: Phaser.GameObjects.Group#isFull
Since: 3.0.0
Focus
Focus
kill(gameObject)
Focus
Focus

Description:

Deactivates a member of this group.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

A member of this group.

Inherited from: Phaser.GameObjects.Group#kill
Since: 3.0.0
Focus
Focus
killAndHide(gameObject)
Focus
Focus

Description:

Deactivates and hides a member of this group.

Parameters:

name type description
gameObject Phaser.GameObjects.GameObject

A member of this group.

Inherited from: Phaser.GameObjects.Group#killAndHide
Since: 3.0.0
Focus
Focus
listenerCount(event)
Focus
Focus

Description:

Return the number of listeners listening to a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The number of listeners.

Type:
  • number
Inherited from: Phaser.Events.EventEmitter#listenerCount
Since: 3.0.0
Focus
Focus
listeners(event)
Focus
Focus

Description:

Return the listeners registered for a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The registered listeners.

Type:
  • Array.<function()>
Inherited from: Phaser.Events.EventEmitter#listeners
Since: 3.0.0
Focus
Focus
off(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#off
Since: 3.0.0
Focus
Focus
on(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#on
Since: 3.0.0
Focus
Focus
once(event, fn, [context])
Focus
Focus

Description:

Add a one-time listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#once
Since: 3.0.0
Focus
Focus
playAnimation(key, [startFrame])
Focus
Focus

Description:

Plays an animation for all members of this group.

Parameters:

name type arguments description
key string

The string-based key of the animation to play.

startFrame string <optional>

Optionally start the animation playing from this frame index.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#playAnimation
Since: 3.0.0
Focus
Focus
preUpdate(time, delta)
Focus
Focus

Description:

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.

Inherited from: Phaser.GameObjects.Group#preUpdate
Since: 3.0.0
Focus
Focus
propertyValueInc(key, value, [step], [index], [direction])
Focus
Focus

Description:

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

Parameters:

name type arguments 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 number <optional> 0

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

direction number <optional> 1

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#propertyValueInc
Since: 3.21.0
Focus
Focus
propertyValueSet(key, value, [step], [index], [direction])
Focus
Focus

Description:

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

Parameters:

name type arguments 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 number <optional> 0

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

direction number <optional> 1

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#propertyValueSet
Since: 3.21.0
Focus
Focus
refresh()
Focus
Focus

Description:

Resets each Body to the position of its parent Game Object. Body sizes aren't changed (use Phaser.Physics.Arcade.Components.Enable#refreshBody for that).

Returns:
Description:

This group.

Since: 3.0.0
Focus
Focus
remove(child, [removeFromScene], [destroyChild])
Focus
Focus

Description:

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 arguments 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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#remove
Since: 3.0.0
Focus
Focus
removeAllListeners([event])
Focus
Focus

Description:

Remove all listeners, or those of the specified event.

Parameters:

name type arguments description
event string | symbol <optional>

The event name.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeAllListeners
Since: 3.0.0
Focus
Focus
removeCallbackHandler(child)
Focus
Focus

Description:

Disables the group member's physics body, removing it from the simulation.

Parameters:

name type description
child Phaser.GameObjects.GameObject

The group member being removed.

Since: 3.0.0
Focus
Focus
removeListener(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeListener
Since: 3.0.0
Focus
Focus
rotate(value, [step])
Focus
Focus

Description:

Sets the rotation of each group member.

Parameters:

name type arguments description
value number

The amount to set the rotation to, in radians.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#rotate
Since: 3.21.0
Focus
Focus
rotateAround(point, angle)
Focus
Focus

Description:

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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#rotateAround
Since: 3.21.0
Focus
Focus
rotateAroundDistance(point, angle, distance)
Focus
Focus

Description:

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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#rotateAroundDistance
Since: 3.21.0
Focus
Focus
scaleX(value, [step])
Focus
Focus

Description:

Sets the scaleX of each group member.

Parameters:

name type arguments description
value number

The amount to set the property to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#scaleX
Since: 3.21.0
Focus
Focus
scaleXY(scaleX, [scaleY], [stepX], [stepY])
Focus
Focus

Description:

Sets the scaleX, scaleY of each group member.

Parameters:

name type arguments 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>

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

stepY number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#scaleXY
Since: 3.21.0
Focus
Focus
scaleY(value, [step])
Focus
Focus

Description:

Sets the scaleY of each group member.

Parameters:

name type arguments description
value number

The amount to set the property to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#scaleY
Since: 3.21.0
Focus
Focus
setActive(value)
Focus
Focus

Description:

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

Parameters:

name type description
value boolean

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setActive
Since: 3.24.0
Focus
Focus
setAlpha(value, [step])
Focus
Focus

Description:

Sets the alpha of each group member.

Parameters:

name type arguments description
value number

The amount to set the alpha to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setAlpha
Since: 3.21.0
Focus
Focus
setBlendMode(value)
Focus
Focus

Description:

Sets the blendMode of each group member.

Parameters:

name type description
value number

The amount to set the property to.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setBlendMode
Since: 3.21.0
Focus
Focus
setDepth(value, [step])
Focus
Focus

Description:

Sets the depth of each group member.

Parameters:

name type arguments description
value number

The amount to set the property to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setDepth
Since: 3.0.0
Focus
Focus
setHitArea(hitArea, hitAreaCallback)
Focus
Focus

Description:

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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setHitArea
Since: 3.21.0
Focus
Focus
setName(value)
Focus
Focus

Description:

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

Parameters:

name type description
value string

The name to be given to this Group.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setName
Since: 3.24.0
Focus
Focus
setOrigin(originX, [originY], [stepX], [stepY])
Focus
Focus

Description:

Sets the originX, originY of each group member.

Parameters:

name type arguments 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>

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

stepY number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setOrigin
Since: 3.21.0
Focus
Focus
setTint(topLeft, [topRight], [bottomLeft], [bottomRight])
Focus
Focus

Description:

Sets the tint of each group member.

Parameters:

name type arguments 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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setTint
Since: 3.21.0
Focus
Focus
setVisible(value, [index], [direction])
Focus
Focus

Description:

Sets the visible of each group member.

Parameters:

name type arguments Default description
value boolean

The value to set the property to.

index number <optional> 0

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

direction number <optional> 1

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setVisible
Since: 3.21.0
Focus
Focus
setX(value, [step])
Focus
Focus

Description:

Sets the x of each group member.

Parameters:

name type arguments description
value number

The amount to set the property to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setX
Since: 3.21.0
Focus
Focus
setXY(x, [y], [stepX], [stepY])
Focus
Focus

Description:

Sets the x, y of each group member.

Parameters:

name type arguments 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.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setXY
Since: 3.21.0
Focus
Focus
setY(value, [step])
Focus
Focus

Description:

Sets the y of each group member.

Parameters:

name type arguments description
value number

The amount to set the property to.

step number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#setY
Since: 3.21.0
Focus
Focus
shiftPosition(x, y, [direction])
Focus
Focus

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:

name type arguments 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 number <optional>

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#shiftPosition
Since: 3.21.0
Focus
Focus
shuffle()
Focus
Focus

Description:

Shuffles the group members in place.

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#shuffle
Since: 3.21.0
Focus
Focus
shutdown()
Focus
Focus

Description:

Removes all listeners.

Inherited from: Phaser.Events.EventEmitter#shutdown
Since: 3.0.0
Focus
Focus
toggleVisible()
Focus
Focus

Description:

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

Returns:
Description:

This Group object.

Inherited from: Phaser.GameObjects.Group#toggleVisible
Since: 3.0.0
Focus
Focus