Phaser API Documentation

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

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
Since: 3.6.0