Phaser API Documentation

  Version: 
Filter

A Set is a collection of unique elements.

Constructor:

new Set([elements])

Parameters:

name type arguments description
elements Array.<*> <optional>

An optional array of elements to insert into this Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 18)

Members

entries: Array.<*>
Focus
Focus

Description:

The entries of this Set. Stored internally as an array.

Type:
Array.<*>
Default: []
Since: 3.0.0
Source: src/structs/Set.js (Line 38)
Focus
Focus
size: number
Focus
Focus

Description:

The size of this Set. This is the number of entries within it. Changing the size will truncate the Set if the given value is smaller than the current size. Increasing the size larger than the current size has no effect.

Type:
number
Since: 3.0.0
Source: src/structs/Set.js (Line 416)
Focus
Focus

Methods

clear()
Focus
Focus

Description:

Clears this Set so that it no longer contains any values.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 299)
Focus
Focus
contains(value)
Focus
Focus

Description:

Returns true if this Set contains the given value, otherwise returns false.

Parameters:

name type description
value *

The value to check for in this Set.

Returns:
Description:

true if the given value was found in this Set, otherwise false.

Type:
  • boolean
Since: 3.0.0
Source: src/structs/Set.js (Line 316)
Focus
Focus
delete(value)
Focus
Focus

Description:

Removes the given value from this Set if this Set contains that value.

Parameters:

name type description
value *

The value to remove from the Set.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 124)
Focus
Focus
difference(set)
Focus
Focus

Description:

Returns a new Set containing all the values in this Set which are not also in the given Set.

Parameters:

name type description
set Phaser.Structs.Set

The Set to perform the difference with.

Returns:
Description:

A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method.

Since: 3.0.0
Source: src/structs/Set.js (Line 389)
Focus
Focus
dump()
Focus
Focus

Description:

Dumps the contents of this Set to the console via console.group.

Since: 3.0.0
Source: src/structs/Set.js (Line 149)
Focus
Focus
each(callback, [callbackScope])
Focus
Focus

Description:

Passes each value in this Set to the given callback. Use this function when you know this Set will be modified during the iteration, otherwise use iterate.

Parameters:

name type arguments description
callback EachSetCallback

The callback to be invoked and passed each value this Set contains.

callbackScope * <optional>

The scope of the callback.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 170)
Focus
Focus
get(property, value)
Focus
Focus

Description:

Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. If no elements of this Set satisfy the condition then this method will return null.

Parameters:

name type description
property string

The property name to check on the elements of this Set.

value *

The value to check for.

Returns:
Description:

The first element of this Set that meets the required condition, or null if this Set contains no elements that meet the condition.

Type:
  • *
Since: 3.0.0
Source: src/structs/Set.js (Line 82)
Focus
Focus
getArray()
Focus
Focus

Description:

Returns an array containing all the values in this Set.

Returns:
Description:

An array containing all the values in this Set.

Type:
  • Array.<*>
Since: 3.0.0
Source: src/structs/Set.js (Line 109)
Focus
Focus
intersect(set)
Focus
Focus

Description:

Returns a new Set that contains only the values which are in this Set and that are also in the given Set.

Parameters:

name type description
set Phaser.Structs.Set

The Set to intersect this set with.

Returns:
Description:

The result of the intersection, as a new Set.

Since: 3.0.0
Source: src/structs/Set.js (Line 362)
Focus
Focus
iterate(callback, [callbackScope])
Focus
Focus

Description:

Passes each value in this Set to the given callback.

For when you absolutely know this Set won't be modified during the iteration.

The callback must return a boolean. If it returns false then it will abort the Set iteration immediately. If it returns true, it will carry on iterating the next child in the Set.

Parameters:

name type arguments description
callback EachSetCallback

The callback to be invoked and passed each value this Set contains.

callbackScope * <optional>

The scope of the callback.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 215)
Focus
Focus
iterateLocal(callbackKey, [args])
Focus
Focus

Description:

Goes through each entry in this Set and invokes the given function on them, passing in the arguments.

Parameters:

name type arguments description
callbackKey string

The key of the function to be invoked on each Set entry.

args * <optional>

Additional arguments that will be passed to the callback, after the child.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 264)
Focus
Focus
set(value)
Focus
Focus

Description:

Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect.

Parameters:

name type description
value *

The value to insert into this Set.

Returns:
Description:

This Set object.

Since: 3.0.0
Source: src/structs/Set.js (Line 59)
Focus
Focus
union(set)
Focus
Focus

Description:

Returns a new Set containing all values that are either in this Set or in the Set provided as an argument.

Parameters:

name type description
set Phaser.Structs.Set

The Set to perform the union with.

Returns:
Description:

A new Set containing all the values in this Set and the Set provided as an argument.

Since: 3.0.0
Source: src/structs/Set.js (Line 333)
Focus
Focus