new Group(game, parent, name, useStage)
Phaser Group constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
parent |
Description | Description. |
name |
string | The unique name for this animation, used in playback commands. |
useStage |
boolean | Description. |
- Source:
- core/Group.js, line 18
Members
-
exists
-
- Default Value:
- true
- Source:
- core/Group.js, line 72
Properties:
Name Type Description existsboolean Description. -
game
-
- Source:
- core/Group.js, line 30
Properties:
Name Type Description gamePhaser.Game A reference to the currently running Game. -
name
-
- Source:
- core/Group.js, line 35
Properties:
Name Type Description namePhaser.Game Description. -
type
-
- Source:
- core/Group.js, line 66
Properties:
Name Type Description typeDescription Description.
Methods
-
<static> add(child) → {Description}
-
Description.
Parameters:
Name Type Description childDescription Description. - Source:
- core/Group.js, line 85
Returns:
Description.- Type
- Description
-
<static> addAll(property, amount, checkAlive, checkVisible)
-
Adds the amount to the given property on all children in this Group. Group.addAll('x', 10) will add 10 to the child.x value.
Parameters:
Name Type Description propertystring The property to increment, for example 'body.velocity.x' or 'angle'. amountnumber The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. checkAliveboolean If true the property will only be changed if the child is alive. checkVisibleboolean If true the property will only be changed if the child is visible. - Source:
- core/Group.js, line 481
-
<static> addAt(child, index) → {Description}
-
Description.
Parameters:
Name Type Description childDescription Description. indexDescription Description. - Source:
- core/Group.js, line 111
Returns:
Description.- Type
- Description
-
<static> bringToTop(child) → {Description}
-
Description.
Parameters:
Name Type Description childDescription Description. - Source:
- core/Group.js, line 313
Returns:
Description.- Type
- Description
-
<static> callAll(callback, parameter)
-
Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child.
Parameters:
Name Type Argument Description callbackfunction The function that exists on the children that will be called. parameter* <repeatable>
Additional parameters that will be passed to the callback. - Source:
- core/Group.js, line 582
-
<static> callAllExists(callback, existsValue, parameter)
-
Calls a function on all of the children that have exists=true in this Group. After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback.
Parameters:
Name Type Argument Description callbackfunction The function that exists on the children that will be called. existsValueboolean Only children with exists=existsValue will be called. parameter* <repeatable>
Additional parameters that will be passed to the callback. - Source:
- core/Group.js, line 549
-
<static> countDead() → {number}
-
Call this function to find out how many members of the group are dead.
- Source:
- core/Group.js, line 845
Returns:
The number of children flagged as dead. Returns -1 if Group is empty.- Type
- number
-
<static> countLiving() → {number}
-
Call this function to find out how many members of the group are alive.
- Source:
- core/Group.js, line 814
Returns:
The number of children flagged as alive. Returns -1 if Group is empty.- Type
- number
-
<static> create(x, y, key, frame, exists) → {Description}
-
Description.
Parameters:
Name Type Argument Description xnumber Description. ynumber Description. keystring Description. framestring <optional>
Description. existsboolean <optional>
Description. - Source:
- core/Group.js, line 152
Returns:
Description.- Type
- Description
-
<static> destroy()
-
Description.
- Source:
- core/Group.js, line 968
-
<static> divideAll(property, amount, checkAlive, checkVisible)
-
Divides the given property by the amount on all children in this Group. Group.divideAll('x', 2) will half the child.x value.
Parameters:
Name Type Description propertystring The property to divide, for example 'body.velocity.x' or 'angle'. amountnumber The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. checkAliveboolean If true the property will only be changed if the child is alive. checkVisibleboolean If true the property will only be changed if the child is visible. - Source:
- core/Group.js, line 532
-
<static> dump()
-
Description.
- Source:
- core/Group.js, line 988
-
<static> forEach(callback, callbackContext, checkExists)
-
Description. After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child.
Parameters:
Name Type Description callbackDescription Description. callbackContextDescription Description. checkExistsboolean Description. - Source:
- core/Group.js, line 614
-
<static> forEachAlive(callback, callbackContext)
-
Description.
Parameters:
Name Type Description callbackDescription Description. callbackContextDescription Description. - Source:
- core/Group.js, line 654
-
<static> forEachDead(callback, callbackContext)
-
Description.
Parameters:
Name Type Description callbackDescription Description. callbackContextDescription Description. - Source:
- core/Group.js, line 687
-
<static> getAt(index) → {Description}
-
Description.
Parameters:
Name Type Description indexDescription Description. - Source:
- core/Group.js, line 138
Returns:
Description.- Type
- Description
-
<static> getFirstAlive() → {Any}
-
Call this function to retrieve the first object with alive == true in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
- Source:
- core/Group.js, line 754
Returns:
The first alive child, or null if none found.- Type
- Any
-
<static> getFirstDead() → {Any}
-
Call this function to retrieve the first object with alive == false in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
- Source:
- core/Group.js, line 784
Returns:
The first dead child, or null if none found.- Type
- Any
-
<static> getFirstExists(state) → {Any}
-
Call this function to retrieve the first object with exists == (the given state) in the group.
Parameters:
Name Type Description stateDescription Description. - Source:
- core/Group.js, line 719
Returns:
The first child, or null if none found.- Type
- Any
-
<static> getIndex(child) → {Description}
-
Description.
Parameters:
Name Type Description childDescription Description. - Source:
- core/Group.js, line 333
Returns:
Description.- Type
- Description
-
<static> getRandom(startIndex, length) → {Any}
-
Returns a member at random from the group.
Parameters:
Name Type Description startIndexnumber Optional offset off the front of the array. Default value is 0, or the beginning of the array. lengthnumber Optional restriction on the number of values you want to randomly select from. - Source:
- core/Group.js, line 876
Returns:
A random child of this Group.- Type
- Any
-
<static> multiplyAll(property, amount, checkAlive, checkVisible)
-
Multiplies the given property by the amount on all children in this Group. Group.multiplyAll('x', 2) will x2 the child.x value.
Parameters:
Name Type Description propertystring The property to multiply, for example 'body.velocity.x' or 'angle'. amountnumber The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. checkAliveboolean If true the property will only be changed if the child is alive. checkVisibleboolean If true the property will only be changed if the child is visible. - Source:
- core/Group.js, line 515
-
<static> remove(child)
-
Description.
Parameters:
Name Type Description childDescription Description. - Source:
- core/Group.js, line 899
-
<static> removeAll()
-
Description.
- Source:
- core/Group.js, line 914
-
<static> removeBetween(startIndex, endIndex)
-
Description.
Parameters:
Name Type Description startIndexDescription Description. endIndexDescription Description. - Source:
- core/Group.js, line 939
-
<static> replace(oldChild, newChild)
-
Description.
Parameters:
Name Type Description oldChildDescription Description. newChildDescription Description. - Source:
- core/Group.js, line 347
-
<static> setAll(key, value, checkAlive, checkVisible, operation)
-
Description.
Parameters:
Name Type Description keyDescription Description. valueDescription Description. checkAliveDescription Description. checkVisibleDescription Description. operationDescription Description. - Source:
- core/Group.js, line 443
-
<static> setProperty(child, key, value, operation) → {number}
-
Description.
Parameters:
Name Type Description childDescription Description. keyarray An array of values that will be set. valueDescription Description. operationDescription Description. - Source:
- core/Group.js, line 379
Returns:
An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). (TODO)- Type
- number
-
<static> subAll(property, amount, checkAlive, checkVisible)
-
Subtracts the amount from the given property on all children in this Group. Group.subAll('x', 10) will minus 10 from the child.x value.
Parameters:
Name Type Description propertystring The property to decrement, for example 'body.velocity.x' or 'angle'. amountnumber The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. checkAliveboolean If true the property will only be changed if the child is alive. checkVisibleboolean If true the property will only be changed if the child is visible. - Source:
- core/Group.js, line 498
-
<static> swap(child1, child2) → {boolean}
-
Description.
Parameters:
Name Type Description child1Description Description. child2Description Description. - Source:
- core/Group.js, line 184
Returns:
Description.- Type
- boolean