Phaser API Documentation

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

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