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:
Members
-
angle
-
The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
- Source:
Properties:
Name Type Description angle
number The angle of rotation given in degrees, where 0 degrees = to the right.
-
exists
-
- Default Value:
- true
- Source:
Properties:
Name Type Description exists
boolean Description.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running Game.
-
length
-
- Source:
Properties:
Name Type Description length
number The number of children in this Group.
-
name
-
- Source:
Properties:
Name Type Description name
Phaser.Game Description.
-
rotation
-
The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
- Source:
Properties:
Name Type Description rotation
number The angle of rotation given in radians.
-
type
-
- Source:
Properties:
Name Type Description type
Description Description.
-
visible
-
- Source:
Properties:
Name Type Description visible
boolean The visible state of the Group. Non-visible Groups and all of their children are not rendered.
-
x
-
The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
- Source:
Properties:
Name Type Description x
number The x coordinate of the Group container.
-
y
-
The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
- Source:
Properties:
Name Type Description y
number The y coordinate of the Group container.
Methods
-
add(child) → {Description}
-
Description.
Parameters:
Name Type Description child
Description Description.
- Source:
Returns:
Description.
- Type
- Description
-
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 property
string The property to increment, for example 'body.velocity.x' or 'angle'.
amount
number The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50.
checkAlive
boolean If true the property will only be changed if the child is alive.
checkVisible
boolean If true the property will only be changed if the child is visible.
- Source:
-
addAt(child, index) → {Description}
-
Description.
Parameters:
Name Type Description child
Description Description.
index
Description Description.
- Source:
Returns:
Description.
- Type
- Description
-
bringToTop(child) → {Description}
-
Description.
Parameters:
Name Type Description child
Description Description.
- Source:
Returns:
Description.
- Type
- Description
-
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 callback
function The function that exists on the children that will be called.
parameter
* <repeatable>
Additional parameters that will be passed to the callback.
- Source:
-
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 callback
function The function that exists on the children that will be called.
existsValue
boolean Only children with exists=existsValue will be called.
parameter
* <repeatable>
Additional parameters that will be passed to the callback.
- Source:
-
countDead() → {number}
-
Call this function to find out how many members of the group are dead.
- Source:
Returns:
The number of children flagged as dead. Returns -1 if Group is empty.
- Type
- number
-
countLiving() → {number}
-
Call this function to find out how many members of the group are alive.
- Source:
Returns:
The number of children flagged as alive. Returns -1 if Group is empty.
- Type
- number
-
create(x, y, key, frame, exists) → {Description}
-
Description.
Parameters:
Name Type Argument Description x
number Description.
y
number Description.
key
string Description.
frame
string <optional>
Description.
exists
boolean <optional>
Description.
- Source:
Returns:
Description.
- Type
- Description
-
destroy()
-
Description.
- Source:
-
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 property
string The property to divide, for example 'body.velocity.x' or 'angle'.
amount
number The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50.
checkAlive
boolean If true the property will only be changed if the child is alive.
checkVisible
boolean If true the property will only be changed if the child is visible.
- Source:
-
dump()
-
Description.
- Source:
-
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 callback
Description Description.
callbackContext
Description Description.
checkExists
boolean Description.
- Source:
-
forEachAlive(callback, callbackContext)
-
Description.
Parameters:
Name Type Description callback
Description Description.
callbackContext
Description Description.
- Source:
-
forEachDead(callback, callbackContext)
-
Description.
Parameters:
Name Type Description callback
Description Description.
callbackContext
Description Description.
- Source:
-
getAt(index) → {Description}
-
Description.
Parameters:
Name Type Description index
Description Description.
- Source:
Returns:
Description.
- Type
- Description
-
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:
Returns:
The first alive child, or null if none found.
- Type
- Any
-
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:
Returns:
The first dead child, or null if none found.
- Type
- Any
-
getFirstExists(state) → {Any}
-
Call this function to retrieve the first object with exists == (the given state) in the group.
Parameters:
Name Type Description state
Description Description.
- Source:
Returns:
The first child, or null if none found.
- Type
- Any
-
getIndex(child) → {Description}
-
Description.
Parameters:
Name Type Description child
Description Description.
- Source:
Returns:
Description.
- Type
- Description
-
getRandom(startIndex, length) → {Any}
-
Returns a member at random from the group.
Parameters:
Name Type Description startIndex
number Optional offset off the front of the array. Default value is 0, or the beginning of the array.
length
number Optional restriction on the number of values you want to randomly select from.
- Source:
Returns:
A random child of this Group.
- Type
- Any
-
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 property
string The property to multiply, for example 'body.velocity.x' or 'angle'.
amount
number The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20.
checkAlive
boolean If true the property will only be changed if the child is alive.
checkVisible
boolean If true the property will only be changed if the child is visible.
- Source:
-
remove(child)
-
Description.
Parameters:
Name Type Description child
Description Description.
- Source:
-
removeAll()
-
Description.
- Source:
-
removeBetween(startIndex, endIndex)
-
Description.
Parameters:
Name Type Description startIndex
Description Description.
endIndex
Description Description.
- Source:
-
replace(oldChild, newChild)
-
Description.
Parameters:
Name Type Description oldChild
Description Description.
newChild
Description Description.
- Source:
-
setAll(key, value, checkAlive, checkVisible, operation)
-
Description.
Parameters:
Name Type Description key
Description Description.
value
Description Description.
checkAlive
Description Description.
checkVisible
Description Description.
operation
Description Description.
- Source:
-
setProperty(child, key, value, operation) → {number}
-
Description.
Parameters:
Name Type Description child
Description Description.
key
array An array of values that will be set.
value
Description Description.
operation
Description Description.
- Source:
Returns:
An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). (TODO)
- Type
- number
-
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 property
string The property to decrement, for example 'body.velocity.x' or 'angle'.
amount
number The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10.
checkAlive
boolean If true the property will only be changed if the child is alive.
checkVisible
boolean If true the property will only be changed if the child is visible.
- Source:
-
swap(child1, child2) → {boolean}
-
Description.
Parameters:
Name Type Description child1
Description Description.
child2
Description Description.
- Source:
Returns:
Description.
- Type
- boolean