new Map(elements)
Parameters:
| Name | Type | Description |
|---|---|---|
elements |
Array.<*> | An optional array of key-value pairs to populate this Map with. |
- Since: 3.0.0
- Source: src/structs/Map.js (Line 18)
Members
-
entries :Object.<string, *>
-
The entries in this Map.
Type:
- Object.<string, *>
- Since: 3.0.0
- Default Value:
-
- {}
- Source: src/structs/Map.js (Line 47)
-
size :number
-
The number of key / value pairs in this Map.
Type:
- number
- Since: 3.0.0
- Default Value:
-
- 0
- Source: src/structs/Map.js (Line 59)
Methods
-
clear()
-
Delete all entries from this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 191)
Returns:
This Map object.
- Type
- Phaser.Structs.Map
-
contains(value)
-
Returns
trueif the value exists within this Map. Otherwise, returnsfalse.Parameters:
Name Type Description value* The value to search for.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 304)
Returns:
trueif the value is found, otherwisefalse.- Type
- boolean
-
delete(key)
-
Delete the specified element from this Map.
Parameters:
Name Type Description keystring The key of the element to delete from this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 167)
Returns:
This Map object.
- Type
- Phaser.Structs.Map
-
dump()
-
Dumps the contents of this Map to the console via
console.group.- Since: 3.0.0
- Source: src/structs/Map.js (Line 252)
-
each(callback)
-
Iterates through all entries in this Map, passing each one to the given callback.
If the callback returns
false, the iteration will break.Parameters:
Name Type Description callbackEachMapCallback The callback which will receive the keys and entries held in this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 274)
Returns:
This Map object.
- Type
- Phaser.Structs.Map
-
get(key)
-
Returns the value associated to the
key, orundefinedif there is none.Parameters:
Name Type Description keystring The key of the element to return from the
Mapobject.- Since: 3.0.0
- Source: src/structs/Map.js (Line 106)
Returns:
The element associated with the specified key or
undefinedif the key can't be found in this Map object.- Type
- *
-
getArray()
-
Returns an
Arrayof all the values stored in this Map.- Since: 3.0.0
- Source: src/structs/Map.js (Line 127)
Returns:
An array of the values stored in this Map.
- Type
- Array.<*>
-
has(key)
-
Returns a boolean indicating whether an element with the specified key exists or not.
Parameters:
Name Type Description keystring The key of the element to test for presence of in this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 150)
Returns:
Returns
trueif an element with the specified key exists in this Map, otherwisefalse.- Type
- boolean
-
keys()
-
Returns all entries keys in this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 214)
Returns:
Array containing entries' keys.
- Type
- Array.<string>
-
merge(map [, override])
-
Merges all new keys from the given Map into this one. If it encounters a key that already exists it will be skipped unless override is set to
true.Parameters:
Name Type Argument Default Description mapPhaser.Structs.Map The Map to merge in to this Map.
overrideboolean <optional>
false Set to
trueto replace values in this Map with those from the source map, orfalseto skip them.- Since: 3.0.0
- Source: src/structs/Map.js (Line 331)
Returns:
This Map object.
- Type
- Phaser.Structs.Map
-
set(key, value)
-
Adds an element with a specified
keyandvalueto this Map. If thekeyalready exists, the value will be replaced.Parameters:
Name Type Description keystring The key of the element to be added to this Map.
value* The value of the element to be added to this Map.
- Since: 3.0.0
- Source: src/structs/Map.js (Line 78)
Returns:
This Map object.
- Type
- Phaser.Structs.Map
-
values()
-
Returns an
Arrayof all entries.- Since: 3.0.0
- Source: src/structs/Map.js (Line 229)
Returns:
An
Arrayof entries.- Type
- Array.<*>
