Grape.GameObjectArray Class
A special array, which contains GameObjects and provides the same methods as the GameObject. The methods iterate through the elements, and calls the same method for each element with the given parameters.
Constructor
Grape.GameObjectArray
()
Methods
apply
-
which -
params
Calls a method of each item, but the parameters are passed as an array like in Function.prototype.apply
Parameters:
-
whichStringThe method name to call
-
paramsArrayThe method parameters
Returns:
this
attr
-
name -
newVal
Sets an attribute on each item.
Parameters:
-
nameStringThe attribute name
-
newValThe new value of the attribute
Returns:
this
call
-
which
Calls a method of each item. The subsequent parameters are passed to the method.
Parameters:
-
whichStringThe method name to call
Returns:
this
clone
()
Clones the array (shallow copy) by creating a new instance of the current class.
Returns:
The cloned array
eq
-
i
Creates a new instance of the current class, containing the item at the index i if exists, or an empty array
Parameters:
-
iNumberThe index
Returns:
The array containing 0 or 1 item
get
-
i
Returns an item at the given position. Equivalent to arr[i].
Parameters:
-
iNumberThe index of the item to return
Returns:
The item at the given position
isEmpty
()
Boolean
Returns true if the length of the array is 0.
Returns:
true, if length is 0
one
()
Returns one (the first) item from the array.
Returns:
The first item
random
-
num
Returns a new instance of the current class containing random items from the original array.
Parameters:
-
numNumber | UndefinedThe number of random items. If not set returns one item.
Returns:
The random items
size
()
Number
Returns the length of the array.
Returns:
The size of the array
toArray
()
Array
Creates a native Array by copying the items
Returns:
The native Array
