Class Fz2D.Group

Defined in: src/scene/objects/group.coffee
Inherits: Fz2D.Object

Overview

Public: Group

Instance Method Summary

Inherited Method Summary

Methods inherited from Fz2D.Object

.constructor, .kill, .reset, .show, .hide, .draw, .update

Constructor Details

::constructor(x = 0, y = 0, w = 0, h = 0) Source

Public: Constructor. x - position on the X axis (default: 0) y - position on the Y axis (default: 0) w - width of group (default: 0) h - height of group (default: 0)

Parameters:

  • xposition on the X axis (default: 0)
  • yposition on the Y axis (default: 0)
  • wwidth of group (default: 0)
  • hheight of group (default: 0)

Instance Method Details

::add(object) Source

Public: Adds an object. object - Fz2D.Object Returns the object itself.

Parameters:

Returns:

  • Returns the object itself.

::allAlive() Source

Public: Returns true if all objects are alive.

::allDead() Source

Public: Returns true if all objects are dead.

::any() Source

Public: Returns true if the group has at least one object.

::at(i) Source

Public: Returns object at a given index. i - index (>= 0 and <= length - 1)

Parameters:

  • iindex (>= 0 and <= length

::clear() Source

Public: Removes all objects.

::draw(ctx) Source

Public: Draws group on every frame. ctx - Fz2D.Canvas

Parameters:

::each(cb) Source

Public: Iterates over each object. cb - iteration callback function

Parameters:

  • cbiteration callback function

::eachByClass(klass, cb) Source

Public: Iterates over each object of a given class. klass - a class cb - iteration callback function

Parameters:

  • klassa class
  • cbiteration callback function

::find(cb, arg) Source

Public: Iterates over each object and calls the given callback. cb - iteration callback function arg - additional argument to be passed to the callback function Returns the first object for which the callback function returned true.

Parameters:

  • cbiteration callback function
  • argadditional argument to be passed to the callback function

Returns:

  • Returns the first object for which the callback function returned true.

::findByClass(klass) Source

Public: Finds an object by class. klass - class of the object Returns the object or null.

Parameters:

  • klassclass of the object

Returns:

  • Returns the object or null.

::findByTag(tag) Source

Public: Finds an object by tag. tag - name of the object Returns the object or null.

Parameters:

  • tagname of the object

Returns:

  • Returns the object or null.

::first() Source

Public: Returns first object.

::firstAlive() Source

Public: Returns first Fz2D.Object that is alive.

::firstAliveByClass(klass) Source

Public: Returns first Fz2D.Object by class that is alive. klass - class of the object

Parameters:

  • klassclass of the object

::firstAliveByTag(tag) Source

Public: Returns first Fz2D.Object by tag that is alive. tag - name of the object

Parameters:

  • tagname of the object

::firstAvail() Source

Public: Returns first Fz2D.Object that doesn't exist.

::firstAvailByClass(klass) Source

Public: Returns first Fz2D.Object by class that doesn't exist. klass - class of the object

Parameters:

  • klassclass of the object

::firstAvailByTag(tag) Source

Public: Returns first Fz2D.Object by tag that doesn't exist. tag - name of the object

Parameters:

  • tagname of the object

::firstDead() Source

Public: Returns first Fz2D.Object that is dead.

::firstDeadByClass(klass) Source

Public: Returns first Fz2D.Object by class that is dead. klass - class of the object

Parameters:

  • klassclass of the object

::firstDeadByTag(tag) Source

Public: Returns first Fz2D.Object by tag that is dead. tag - name of the object

Parameters:

  • tagname of the object

::firstExisting() Source

Public: Returns first Fz2D.Object that exist.

::firstExistingByClass(klass) Source

Public: Returns first Fz2D.Object by class that exist. klass - class of the object

Parameters:

  • klassclass of the object

::firstExistingByTag(tag) Source

Public: Returns first Fz2D.Object by tag that exist. tag - name of the object

Parameters:

  • tagname of the object

::firstVisible() Source

Public: Returns first Fz2D.Object that is visible.

::firstVisibleByClass(klass) Source

Public: Returns first Fz2D.Object by class that is visible. klass - class of the object

Parameters:

  • klassclass of the object

::firstVisibleByTag(tag) Source

Public: Returns first Fz2D.Object by tag that is visible. tag - name of the object

Parameters:

  • tagname of the object

::hasAlive() Source

Public: Returns true if there's at least one object that is alive.

::hasAliveByClass(klass) Source

Public: Returns true if there's at least one object that is alive with the given class. klass - class of the object

Parameters:

  • klassclass of the object

::hasAliveByTag(tag) Source

Public: Returns true if there's at least one object that is alive with the given tag. tag - name of the object

Parameters:

  • tagname of the object

::hasDead() Source

Public: Returns true if there's at least one object that is dead.

::hasDeadByClass(klass) Source

Public: Returns true if there's at least one object that is dead with the given class. klass - class of the object

Parameters:

  • klassclass of the object

::hasDeadByTag(tag) Source

Public: Returns true if there's at least one object that is dead with the given tag. tag - name of the object

Parameters:

  • tagname of the object

::hasVisible() Source

Public: Returns true if there's at least one object that is visible.

::hasVisibleByClass(klass) Source

Public: Returns true if there's at least one object that is visible with the given class. klass - class of the object

Parameters:

  • klassclass of the object

::hasVisibleByTag(tag) Source

Public: Returns true if there's at least one object that is visible with the given tag. tag - name of the object

Parameters:

  • tagname of the object

::hide() Source

Public: Hides all objects.

::kill() Source

Public: Kills all objects.

::last() Source

Public: Returns last object.

::length() Source

Public: Returns the number of objects.

::range(i, n, cb) Source

Public: Iterates over all objects within the given range. i - start index n - number of objects to iterate over cb - iteration callback function

Parameters:

  • istart index
  • nnumber of objects to iterate over
  • cbiteration callback function

::recycle() Source

Public: Recycle an object. Returns first Fz2D.Object that doesn't exist.

Fz2D.Object ::recycleByClass(klass) Source

Public: Recycle an object by class. klass - class Returns first Fz2D.Object with the given class that doesn't exist.

Parameters:

  • klassclass

Returns:

Fz2D.Object ::recycleByTag(tag) Source

Public: Recycle an object by tag. tag - name of the object Returns first Fz2D.Object with the given tag that doesn't exist.

Parameters:

  • tagname of the object

Returns:

::remove(object) Source

Public: Removes an object. object - Fz2D.Object Returns the object itself.

Parameters:

Returns:

  • Returns the object itself.

::removeByClass(klass) Source

Public: Removes an object by class. klass - class of the object Returns the object itself.

Parameters:

  • klassclass of the object

Returns:

  • Returns the object itself.

::removeByIndex(i) Source

Public: Removes an object by index. i - index (>= 0 and <= length - 1) Returns the object itself.

Parameters:

  • iindex (>= 0 and <= length

Returns:

  • Returns the object itself.

::removeByTag(tag) Source

Public: Removes an object by tag. tag - name of the object Returns the object itself.

Parameters:

  • tagname of the object

Returns:

  • Returns the object itself.

::reset() Source

Public: Resets all objects.

::reverseFind(cb, arg) Source

Public: Iterates over each object in reverse order and calls the given callback. cb - iteration callback function arg - additional argument to be passed to the callback function Returns the first object for which the callback function returned true.

Parameters:

  • cbiteration callback function
  • argadditional argument to be passed to the callback function

Returns:

  • Returns the first object for which the callback function returned true.

::show() Source

Public: Shows all objects.

::sort(cb) Source

Public: Sorts objects. cb - compare callback function

Parameters:

  • cbcompare callback function

::sortByZ() Source

Public: Sorts objects by their z value.

::update(timer, input) Source

Public: Updates group on every frame. timer - Fz2D.Timer input - Fz2D.Input

Parameters: