Phaser API Documentation

  Version: 
getFirst(property, value, [startIndex], [endIndex])

Description:

Gets the first Game Object in this Container.

You can also specify a property and value to search for, in which case it will return the first Game Object in this Container with a matching property and / or value.

For example: getFirst('visible', true) would return the first Game Object that had its visible property set.

You can limit the search to the startIndex - endIndex range.

Parameters:

name type arguments Default description
property string

The property to test on each Game Object in the Container.

value *

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

startIndex number <optional> 0

An optional start index to search from.

endIndex number <optional> Container.length

An optional end index to search up to (but not included)

Returns:
Description:

The first matching Game Object, or null if none was found.

Examples:
Since: 3.4.0