API Docs for: 1.0.1

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
)
Grape.Array

Calls a method of each item, but the parameters are passed as an array like in Function.prototype.apply

Parameters:

  • which String

    The method name to call

  • params Array

    The method parameters

Returns:

Grape.Array:

this

attr

(
  • name
  • newVal
)
Grape.Array

Sets an attribute on each item.

Parameters:

  • name String

    The attribute name

  • newVal

    The new value of the attribute

Returns:

Grape.Array:

this

call

(
  • which
)
Grape.Array

Calls a method of each item. The subsequent parameters are passed to the method.

Parameters:

  • which String

    The method name to call

Returns:

Grape.Array:

this

clone

()

Clones the array (shallow copy) by creating a new instance of the current class.

Returns:

:

The cloned array

eq

(
  • i
)
Grape.Array

Creates a new instance of the current class, containing the item at the index i if exists, or an empty array

Parameters:

  • i Number

    The index

Returns:

Grape.Array:

The array containing 0 or 1 item

get

(
  • i
)

Returns an item at the given position. Equivalent to arr[i].

Parameters:

  • i Number

    The 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:

Boolean:

true, if length is 0

one

()

Returns one (the first) item from the array.

Returns:

:

The first item

random

(
  • num
)
Grape.Array

Returns a new instance of the current class containing random items from the original array.

Parameters:

  • num Number | Undefined

    The number of random items. If not set returns one item.

Returns:

Grape.Array:

The random items

size

() Number

Returns the length of the array.

Returns:

Number:

The size of the array

toArray

() Array

Creates a native Array by copying the items

Returns:

Array:

The native Array