Phaser API Documentation

  Version: 

Member of: Phaser.Utils.Array

<static> RemoveRandomElement(array, [start], [length])

Description:

Removes a random object from the given array and returns it. Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index.

Parameters:

name type arguments Default description
array array

The array to removed a random element from.

start number <optional> 0

The array index to start the search from.

length number <optional> array.length

Optional restriction on the number of elements to randomly select from.

Returns:
Description:

The random element that was removed, or null if there were no array elements that fell within the given range.

Type:
  • object
Since: 3.0.0