Phaser . ArraySet

new ArraySet ( list )

ArraySet is a Set data structure (items must be unique within the set) that also maintains order.This allows specific items to be easily added or removed from the Set.

arrayset是一个集合数据结构(集合中的项必须是唯一的),它还维护顺序。这允许在集合中轻松添加或删除特定项。

Item equality (and uniqueness) is determined by the behavior of Array.indexOf .

This used primarily by the Input subsystem.

项的相等性(和唯一性)由array.indexof的行为决定。
这主要由输入子系统使用。

Parameters:
Name Type Argument Default Description
list Array.<any> <optional>
(new array)

The backing array: if specified the items in the list must be unique, per Array.indexOf , and the ownership of the array should be relinquished to the ArraySet.

支持数组:如果指定,则列表中的项必须是唯一的,每个array.indexof,并且数组的所有权应放弃给arrayset。

Source - utils/ArraySet.js , line 19

Members

first :any

Returns the first item and resets the cursor to the start.

返回第一个项并将光标重置为开始。

Source - utils/ArraySet.js , line 231

list :Array.<any>

The backing array.

Type:
  • Array.<any>
Source - utils/ArraySet.js , line 32

next :any

Returns the the next item (based on the cursor) and advances the cursor. 返回下一项(基于光标),并前进光标。

Source - utils/ArraySet.js , line 256

position :integer

Current cursor position as established by first and next . 当前光标位置由第一个和下一个确定。

Source - utils/ArraySet.js , line 26

total :integer

Number of items in the ArraySet. Same as list.length . arrayset中的项数。与list.length相同。

Source - utils/ArraySet.js , line 217

Methods

add (item) → {any}

Adds a new element to the end of the list.If the item already exists in the list it is not moved. 将新元素添加到列表末尾。如果列表中已存在该项,则不会移动该项。

Parameters:
Name Type Description
item any

The element to add to this list. 要添加到此列表中的元素。

Returns:
any -

The item that was added.

任何-添加的项。
Source - utils/ArraySet.js , line 38

callAll (key, parameter)

Calls a function on all members of this list, using the member as the context for the callback.

If the key property is present it must be a function.The function is invoked using the item as the context.

调用此列表中所有成员的函数,将该成员用作回调的上下文。
如果键属性存在,则它必须是一个函数。使用项作为上下文调用该函数。
Parameters:
Name Type Argument Description
key string

The name of the property with the function to call. 具有要调用的函数的属性的名称。

parameter * <repeatable>

Additional parameters that will be passed to the callback. 将传递给回调的其他参数。

Source - utils/ArraySet.js , line 159

exists (item) → {boolean}

Checks for the item within this list. 检查此列表中的项目。

Parameters:
Name Type Description
item any

The element to get the list index for. 要获取其列表索引的元素。

Returns:
boolean -

True if the item is found in the list, otherwise false. 如果在列表中找到该项,则为true,否则为false。

Source - utils/ArraySet.js , line 95

getByKey (property, value) → {any}

Gets an item from the set based on the property strictly equaling the value given.Returns null if not found. 基于严格等于给定的值。如果找不到,则返回空值。

Parameters:
Name Type Description
property string

The property to check against the value. 要根据值检查的属性。

value any

The value to check if the property strictly equals. 用于检查属性是否严格等于的值。

Returns:
any -

The item that was found, or null if nothing matched. 找到的项,如果没有匹配项,则为空。

Source - utils/ArraySet.js , line 70

getIndex (item) → {integer}

Gets the index of the item in the list, or -1 if it isn't in the list. 获取列表中该项的索引,如果该项不在列表中,则为-1。

Parameters:
Name Type Description
item any

The element to get the list index for. 要获取其列表索引的元素。

Returns:
integer -

The index of the item or -1 if not found. 项的索引或-1(如果找不到)。

Source - utils/ArraySet.js , line 57

remove (item) → {any}

Removes the given element from this list if it exists. 从该列表中删除给定元素(如果存在)。

Parameters:
Name Type Description
item any

The item to be removed from the list. 要从列表中删除的项。

Returns:
any -

item - The item that was removed. 项-已删除的项。

Source - utils/ArraySet.js , line 119

removeAll ( destroy )

Removes every member from this ArraySet and optionally destroys it. 从这个arrayset中删除每个成员,并可以选择将其销毁。

Parameters:
Name Type Argument Default Description
destroy boolean <optional>
false

Call destroy on each member as it's removed from this set. 将每个成员从此集中删除时调用destroy。

Source - utils/ArraySet.js , line 185

reset ()

Removes all the items. 删除所有项目。

Source - utils/ArraySet.js , line 108

setAll (key, value)

Sets the property key to the given value on all members of this list. 将此列表中所有成员的属性键设置为给定值。

Parameters:
Name Type Description
key any

The property of the item to set. 要设置的项的属性。

value any

The value to set the property to. 要将属性设置为的值。

Source - utils/ArraySet.js , line 138
Phaser Copyright © 2012-2015 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.2 on Thu Feb 18 2016 14:40:58 GMT+0000 (GMT Standard Time) using the DocStrap template .