Class: Group

Group


new Group()

Provides a transformation hierarchy for Collections

Author:
  • Chris Peters
Source:
Requires:
  • module:Sprite

Extends

Requires

  • module:Sprite

Methods


addItem(item, name)

Add an item with optional name

Parameters:
Name Type Argument Description
item Any

The item to add

name String <optional>

The optional name of the item

Inherited From:
Source:
Returns:
Type
Collection

addItems(items)

Add multiple items

Parameters:
Name Type Argument Description
items Object <repeatable>

Can be the object itself or an object containing the entity and it's name
eg: { item: Entity, name: 'entityName' }

Inherited From:
Source:
Returns:
Type
Collection

each(fn, scope)

Iterates the collection's sorted items. The item, index, and name are supplied
to the provided function

Parameters:
Name Type Argument Description
fn function

The function to execute on the iterable

scope Object <optional>

The scope with which to execute the function

Inherited From:
Source:

filter(fn, scope)

iterates items and return the ones that meet criteria

Parameters:
Name Type Argument Description
fn function

Truth predicate

scope Object <optional>

The scope with which to execute the function

Inherited From:
Source:
Returns:
Type
Array

getItem(name)

Returns an existing item by name, or undefined if the name is not found

Parameters:
Name Type Description
name String

The name of the item

Inherited From:
Source:
Returns:
Type
Any

getItemArray()

Returns a list of just the items

Inherited From:
Source:
Returns:
Type
Array

getItemAt(index)

Returns an existing item by index

Parameters:
Name Type Description
index Integer
Inherited From:
Source:
Returns:
Type
Any

getItemCount()

Returns the count of items in collection

Inherited From:
Source:
Returns:
Type
Integer

getItemIndex(name)

Returns an item's current index

Parameters:
Name Type Description
name String
Inherited From:
Source:
Returns:
Type
Integer

removeAllItems()

Removes all items from collection

Inherited From:
Source:

render(context)

Renders all children recursively on top of own transformation stack

Parameters:
Name Type Description
context Object

The 2d context object

Source:

setItem(name, value)

Assigns a new value to an existing item

Parameters:
Name Type Description
name String

The name of the object to modify

value Any

The new value

Inherited From:
Source:

setItemIndex(name, index)

Moves item to new index

Parameters:
Name Type Description
name String

The name of the object being moved

index Integer

The item's new index

Inherited From:
Source: