Phaser. FlexLayer

Phaser.FlexLayer

new FlexLayer(manager, position, bounds, scale)

WARNING: This is an EXPERIMENTAL class. The API will change significantly in the coming versions and is incomplete. Please try to avoid using in production games with a long time to build. This is also why the documentation is incomplete.

A responsive grid layer.

Parameters:
Name Type Description
manager Phaser.FlexGrid

The FlexGrid that owns this FlexLayer.

position Phaser.Point

A reference to the Point object used for positioning.

bounds Phaser.Rectangle

A reference to the Rectangle used for the layer bounds.

scale Phaser.Point

A reference to the Point object used for layer scaling.

Source - core/FlexLayer.js, line 22

Extends

Members

alive :boolean

The alive property is useful for Groups that are children of other Groups and need to be included/excluded in checks like forEachAlive.

Inherited From:
Default Value:
  • true
Source - core/Group.js, line 70

alpha :number

The alpha value of the Group container.

Inherited From:
Source - core/Group.js, line 1907

angle :number

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. The angle of rotation given in degrees, where 0 degrees = to the right.

Inherited From:
Source - core/Group.js, line 1848

bottomLeft :Phaser.Point

Source - core/FlexLayer.js, line 76

bottomMiddle :Phaser.Point

Source - core/FlexLayer.js, line 81

bottomRight :Phaser.Point

Source - core/FlexLayer.js, line 86

bounds :Phaser.Rectangle

Source - core/FlexLayer.js, line 51

buttonMode :Boolean

This is used to indicate if the displayObject should display a mouse hand cursor on rollover

Inherited From:
Source - pixi/display/DisplayObject.js, line 90

cacheAsBitmap :Boolean

Set if this display object is cached as a bitmap. This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. To remove simply set this property to 'null'

Inherited From:
Source - pixi/display/DisplayObject.js, line 436

cameraOffset :Phaser.Point

If this object is fixedToCamera then this stores the x/y offset that its drawn at, from the top-left of the camera view.

Inherited From:
Source - core/Group.js, line 107

<readonly> children :Array.<DisplayObject>

[read-only] The array of children of this container.

Type:
  • Array.<DisplayObject>
Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 17

classType :object

The type of objects that will be created when you use Group.create or Group.createMultiple. Defaults to Phaser.Sprite. When a new object is created it is passed the following parameters to its constructor: game, x, y, key, frame.

Inherited From:
Source - core/Group.js, line 90

cursor :any

The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions. The cursor is set to the first child added to the Group and doesn't change unless you call next, previous or set it directly with Group.cursor. The current display object that the Group cursor is pointing to.

Inherited From:
Source - core/Group.js, line 102

defaultCursor :String

This is the cursor that will be used when the mouse is over this object. To enable this the element must have interaction = true and buttonMode = true

Inherited From:
Source - pixi/display/DisplayObject.js, line 143

enableBody :boolean

If true all Sprites created by, or added to this Group, will have a physics body enabled on them. Change the body type with Group.physicsBodyType.

Inherited From:
Default Value:
  • enableBody
Source - core/Group.js, line 113

enableBodyDebug :boolean

If true when a physics body is created (via Group.enableBody) it will create a physics debug object as well. Only works for P2 bodies.

Inherited From:
Source - core/Group.js, line 118

exists :boolean

If exists is true the Group is updated, otherwise it is skipped.

Inherited From:
Default Value:
  • true
Source - core/Group.js, line 76

filterArea :PIXI.Rectangle

The area the filter is applied to like the hitArea this is used as more of an optimisation rather than figuring out the dimensions of the displayObject each frame you can set this rectangle

Inherited From:
Source - pixi/display/DisplayObject.js, line 180

filters :Array.<Filter>

Sets the filters for the displayObject. IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer. To remove filters simply set this property to 'null'

Type:
  • Array.<Filter>
Inherited From:
Source - pixi/display/DisplayObject.js, line 400

fixedToCamera :boolean

A Group that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Group.cameraOffset. Note that the cameraOffset values are in addition to any parent in the display list. So if this Group was in a Group that has x: 200, then this will be added to the cameraOffset.x Set to true to fix this Group to the Camera at its current world coordinates.

Inherited From:
Source - core/Group.js, line 1866

game :Phaser.Game

A reference to the currently running Game.

Inherited From:
Source - core/Group.js, line 30

grid :Phaser.FlexGrid

A reference to the FlexGrid that owns this layer.

Source - core/FlexLayer.js, line 34

height :Number

The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 63

hitArea :PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon

This is the defined area that will pick up mouse / touch events. It is null by default. Setting it is a neat way of optimising the hitTest function that the interactionManager will use (as it will not need to hit test all the children)

Type:
Inherited From:
Source - pixi/display/DisplayObject.js, line 81

ignoreDestroy :boolean

A Group with ignoreDestroy set to true ignores all calls to its destroy method.

Inherited From:
Default Value:
  • false
Source - core/Group.js, line 82

interactive :Boolean

Indicates if the sprite will have touch and mouse interactivity. It is false by default

Inherited From:
Default Value:
  • false
Source - pixi/display/DisplayObject.js, line 339

<readonly> length :number

The total number of children in this Group, regardless of their exists/alive status.

Inherited From:
Source - core/Group.js, line 1833

manager

Properties:
Name Type Description
scale Phaser.ScaleManager

A reference to the ScaleManager.

Source - core/FlexLayer.js, line 29

mask :PIXI.Graphics

Sets a mask for the displayObject. A mask is an object that limits the visibility of an object to the shape of the mask applied to it. In PIXI a regular mask must be a PIXI.Graphics object. This allows for much faster masking in canvas as it utilises shape clipping. To remove a mask, set this property to null.

Inherited From:
Source - pixi/display/DisplayObject.js, line 380

name :string

A name for this Group. Not used internally but useful for debugging.

Inherited From:
Source - core/Group.js, line 40

onDestroy :Phaser.Signal

This signal is dispatched if this Group is destroyed.

Inherited From:
Source - core/Group.js, line 128

<readonly> parent :PIXI.DisplayObjectContainer

[read-only] The display object container that contains this display object.

Inherited From:
Source - pixi/display/DisplayObject.js, line 106

persist :boolean

Should the FlexLayer remain through a State swap?

Source - core/FlexLayer.js, line 41

physicsBodyType :number

If Group.enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc.

Inherited From:
Source - core/Group.js, line 123

pivot :PIXI.Point

The pivot point of the displayObject that it rotates around

Inherited From:
Source - pixi/display/DisplayObject.js, line 49

position :Phaser.Point

Source - core/FlexLayer.js, line 46

renderable :Boolean

Can this object be rendered

Inherited From:
Source - pixi/display/DisplayObject.js, line 98

rotation :number

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. The angle of rotation given in radians.

Inherited From:
Source - core/Group.js, line 1903

scale :Phaser.Point

Source - core/FlexLayer.js, line 56

<readonly> stage :PIXI.Stage

[read-only] The stage the display object is connected to, or undefined if it is not connected to the stage.

Inherited From:
Source - pixi/display/DisplayObject.js, line 115

topLeft :Phaser.Point

Source - core/FlexLayer.js, line 61

topMiddle :Phaser.Point

Source - core/FlexLayer.js, line 66

topRight :Phaser.Point

Source - core/FlexLayer.js, line 71

<readonly> total :number

The total number of children in this Group who have a state of exists = true.

Inherited From:
Source - core/Group.js, line 1818

transformCallback :function

The transform callback is an optional callback that if set will be called at the end of the updateTransform method and sent two parameters: This Display Objects worldTransform matrix and its parents transform matrix. Both are PIXI.Matrix object types. The matrix are passed by reference and can be modified directly without needing to return them. This ability allows you to check any of the matrix values and perform actions such as clamping scale or limiting rotation, regardless of the parent transforms.

Inherited From:
Source - pixi/display/DisplayObject.js, line 30

transformCallbackContext :Object

The context under which the transformCallback is invoked.

Inherited From:
Source - pixi/display/DisplayObject.js, line 41

<internal> type :number

Internal Phaser Type value.

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 64

visible :boolean

The visible state of the Group. Non-visible Groups and all of their children are not rendered.

Inherited From:
Source - core/Group.js, line 1905

width :Number

The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 35

<readonly> worldAlpha :Number

[read-only] The multiplied alpha of the displayObject

Inherited From:
Source - pixi/display/DisplayObject.js, line 124

worldVisible :Boolean

[read-only] Indicates if the sprite is globally visible.

Inherited From:
Source - pixi/display/DisplayObject.js, line 359

x :number

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.

Inherited From:
Source - core/Group.js, line 1899

y :number

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.

Inherited From:
Source - core/Group.js, line 1901

z :number

The z-depth value of this object within its Group (remember the World is a Group as well). No two objects in a Group can have the same z value.

Inherited From:
Source - core/Group.js, line 45

Methods

add(child, silent) → {*}

Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control that then see the addAt method.

Parameters:
Name Type Argument Default Description
child *

An instance of Phaser.Sprite, Phaser.Button or any other display object.

silent boolean <optional>
false

If the silent parameter is true the child will not dispatch the onAddedToGroup event.

Returns:
* -

The child that was added to the Group.

Inherited From:
Source - core/Group.js, line 188
See:

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.

Inherited From:
Source - core/Group.js, line 937

addAt(child, index, silent) → {*}

Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. The child is added to the Group at the location specified by the index value, this allows you to control child ordering.

Parameters:
Name Type Argument Default Description
child *

An instance of Phaser.Sprite, Phaser.Button or any other display object..

index number

The index within the Group to insert the child to.

silent boolean <optional>
false

If the silent parameter is true the child will not dispatch the onAddedToGroup event.

Returns:
* -

The child that was added to the Group.

Inherited From:
Source - core/Group.js, line 254

addChild(child) → {PIXI.DisplayObject}

Adds a child to the container.

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject to add to the container

Returns:

The child that was added.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 90

addChildAt(child, index) → {PIXI.DisplayObject}

Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown

Parameters:
Name Type Description
child PIXI.DisplayObject

The child to add

index Number

The index to place the child in

Returns:

The child that was added.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 102

addMultiple(children, silent) → {*}

Adds an array existing objects to this Group. The objects can be instances of Phaser.Sprite, Phaser.Button or any other display object. The children are automatically added to the top of the Group, so render on-top of everything else within the Group. TODO: Add ability to pass the children as parameters rather than having to be an array.

Parameters:
Name Type Argument Default Description
children array

An array containing instances of Phaser.Sprite, Phaser.Button or any other display object.

silent boolean <optional>
false

If the silent parameter is true the children will not dispatch the onAddedToGroup event.

Returns:
* -

The array of children that were added to the Group.

Inherited From:
Source - core/Group.js, line 230

ascendingSortHandler(a, b)

An internal helper function for the sort process.

Parameters:
Name Type Description
a object

The first object being sorted.

b object

The second object being sorted.

Inherited From:
Source - core/Group.js, line 1417

bringToTop(child) → {*}

Brings the given child to the top of this Group so it renders above all other children.

Parameters:
Name Type Description
child *

The child to bring to the top of this Group.

Returns:
* -

The child that was moved.

Inherited From:
Source - core/Group.js, line 493

callAll(method, context, 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 method parameter and context you can add as many extra parameters as you like, which will all be passed to the child.

Parameters:
Name Type Argument Default Description
method string

A string containing the name of the function that will be called. The function must exist on the child.

context string <optional>
null

A string containing the context under which the method will be executed. Set to null to default to the child.

parameter * <repeatable>

Additional parameters that will be passed to the method.

Inherited From:
Source - core/Group.js, line 1082

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.

Inherited From:
Source - core/Group.js, line 1001

<internal> callbackFromArray(child, callback, length)

Returns a reference to a function that exists on a child of the Group based on the given callback array.

Parameters:
Name Type Description
child object

The object to inspect.

callback array

The array of function names.

length number

The size of the array (pre-calculated in callAll).

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1029

checkAll(key, value, checkAlive, checkVisible, force)

This function allows you to quickly check that the same property across all children of this Group is equal to the given value. This call doesn't descend down children, so if you have a Group inside of this Group, the property will be checked on the Group but not its children.

Parameters:
Name Type Argument Default Description
key string

The property, as a string, to be set. For example: 'body.velocity.x'

value *

The value that will be checked.

checkAlive boolean <optional>
false

If set then only children with alive=true will be checked. This includes any Groups that are children.

checkVisible boolean <optional>
false

If set then only children with visible=true will be checked. This includes any Groups that are children.

force boolean <optional>
false

If force is true then the property will be checked on the child regardless if it already exists or not. If true and the property doesn't exist, false will be returned.

Inherited From:
Source - core/Group.js, line 905

checkProperty(child, key, value, force) → {boolean}

Checks a property for the given value on the child.

Parameters:
Name Type Argument Default Description
child *

The child to check the property value on.

key array

An array of strings that make up the property that will be set.

value *

The value that will be checked.

force boolean <optional>
false

If force is true then the property will be checked on the child regardless if it already exists or not. If true and the property doesn't exist, false will be returned.

Returns:
boolean -

True if the property was was equal to value, false if not.

Inherited From:
Source - core/Group.js, line 771

click(interactionData)

A callback that is used when the users clicks on the displayObject with their mouse's left button

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 252

countDead() → {number}

Call this function to find out how many members of the group are dead.

Returns:
number -

The number of children flagged as dead.

Inherited From:
Source - core/Group.js, line 1616

countLiving() → {number}

Call this function to find out how many members of the group are alive.

Returns:
number -

The number of children flagged as alive.

Inherited From:
Source - core/Group.js, line 1604

create(x, y, key, frame, exists) → {Phaser.Sprite|object}

Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. You can change Group.classType to any object and this call will create an object of that type instead, but it should extend either Sprite or Image.

Parameters:
Name Type Argument Default Description
x number

The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.

y number

The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.

key string

The Game.cache key of the image that this Sprite will use.

frame number | string <optional>

If the Sprite image contains multiple frames you can specify which one to use here.

exists boolean <optional>
true

The default exists state of the Sprite.

Returns:
Phaser.Sprite | object -

The child that was created. Will be a Phaser.Sprite unless Group.classType has been changed.

Inherited From:
Source - core/Group.js, line 314

createMultiple(quantity, key, frame, exists)

Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist and will be positioned at 0, 0 (relative to the Group.x/y) You can change Group.classType to any object and this call will create an object of that type instead, but it should extend either Sprite or Image.

Parameters:
Name Type Argument Default Description
quantity number

The number of Sprites to create.

key string

The Game.cache key of the image that this Sprite will use.

frame number | string <optional>

If the Sprite image contains multiple frames you can specify which one to use here.

exists boolean <optional>
false

The default exists state of the Sprite.

Inherited From:
Source - core/Group.js, line 359

customSort(sortHandler, context)

This allows you to use your own sort handler function. It will be sent two parameters: the two children involved in the comparison (a and b). It should return -1 if a > b, 1 if a < b or 0 if a === b.

Parameters:
Name Type Description
sortHandler function

Your sort handler function. It will be sent two parameters: the two children involved in the comparison. It must return -1, 1 or 0.

context object

The scope in which the sortHandler is called.

Inherited From:
Source - core/Group.js, line 1395

debug()

Debug.

Source - core/FlexLayer.js, line 101

descendingSortHandler(a, b)

An internal helper function for the sort process.

Parameters:
Name Type Description
a object

The first object being sorted.

b object

The second object being sorted.

Inherited From:
Source - core/Group.js, line 1448

destroy(destroyChildren, soft)

Destroys this Group. Removes all children, then removes the container from the display list and nulls references.

Parameters:
Name Type Argument Default Description
destroyChildren boolean <optional>
true

Should every child of this Group have its destroy method called?

soft boolean <optional>
false

A 'soft destroy' (set to true) doesn't remove this Group from its parent or null the game reference. Set to false and it does.

Inherited From:
Source - core/Group.js, line 1784

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.

Inherited From:
Source - core/Group.js, line 985

filter(predicate, checkExists) → {Phaser.ArraySet}

Allows you to obtain a Phaser.ArraySet of children that return true for the given predicate For example:

var healthyList = Group.filter(function(child, index, children) {
    return child.health > 10 ? true : false;
}, true);
healthyList.callAll('attack');

Note: Currently this will skip any children which are Groups themselves.

Parameters:
Name Type Argument Default Description
predicate function

The function that each child will be evaluated against. Each child of the Group will be passed to it as its first parameter, the index as the second, and the entire child array as the third

checkExists boolean <optional>
false

If set only children with exists=true will be passed to the callback, otherwise all children will be passed.

Returns:

Returns an array list containing all the children that the predicate returned true for

Inherited From:
Source - core/Group.js, line 1212

forEach(callback, callbackContext, checkExists)

Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. 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. For example: Group.forEach(awardBonusGold, this, true, 100, 500) Note: Currently this will skip any children which are Groups themselves.

Parameters:
Name Type Argument Default Description
callback function

The function that will be called. Each child of the Group will be passed to it as its first parameter.

callbackContext Object

The context in which the function should be called (usually 'this').

checkExists boolean <optional>
false

If set only children with exists=true will be passed to the callback, otherwise all children will be passed.

Inherited From:
Source - core/Group.js, line 1251

forEachAlive(callback, callbackContext)

Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. You can add as many parameters as you like, which will all be passed to the callback along with the child. For example: Group.forEachAlive(causeDamage, this, 500)

Parameters:
Name Type Description
callback function

The function that will be called. Each child of the Group will be passed to it as its first parameter.

callbackContext Object

The context in which the function should be called (usually 'this').

Inherited From:
Source - core/Group.js, line 1317

forEachDead(callback, callbackContext)

Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. You can add as many parameters as you like, which will all be passed to the callback along with the child. For example: Group.forEachDead(bringToLife, this)

Parameters:
Name Type Description
callback function

The function that will be called. Each child of the Group will be passed to it as its first parameter.

callbackContext Object

The context in which the function should be called (usually 'this').

Inherited From:
Source - core/Group.js, line 1339

forEachExists(callback, callbackContext)

Allows you to call your own function on each member of this Group where child.exists=true. You must pass the callback and context in which it will run. You can add as many parameters as you like, which will all be passed to the callback along with the child. For example: Group.forEachExists(causeDamage, this, 500)

Parameters:
Name Type Description
callback function

The function that will be called. Each child of the Group will be passed to it as its first parameter.

callbackContext Object

The context in which the function should be called (usually 'this').

Inherited From:
Source - core/Group.js, line 1295

generateTexture(resolution, scaleMode, renderer) → {PIXI.Texture}

Useful function that returns a texture of the displayObject object that can then be used to create sprites This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times.

Parameters:
Name Type Description
resolution Number

The resolution of the texture being generated

scaleMode Number

See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values

renderer PIXI.CanvasRenderer | PIXI.WebGLRenderer

The renderer used to generate the texture.

Returns:

a texture of the graphics object

Inherited From:
Source - pixi/display/DisplayObject.js, line 582

getAt(index) → {*}

Returns the child found at the given index within this Group.

Parameters:
Name Type Description
index number

The index to return the child from.

Returns:
* -

The child that was found at the given index. If the index was out of bounds then this will return -1.

Inherited From:
Source - core/Group.js, line 294

getBottom() → {Any}

Returns the child at the bottom of this Group. The bottom is the one being displayed (rendered) below every other child.

Returns:
Any -

The child at the bottom of the Group.

Inherited From:
Source - core/Group.js, line 1589

getBounds() → {PIXI.Rectangle}

Retrieves the bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration.

Returns:

The rectangular bounding area

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 302

getChildAt(index) → {PIXI.DisplayObject}

Returns the child at the specified index

Parameters:
Name Type Description
index Number

The index to get the child from

Returns:

The child at the given index, if any.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 193

getChildIndex(child) → {Number}

Returns the index position of a child DisplayObject instance

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject instance to identify

Returns:
Number -

The index position of the child display object to identify

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 158

getFirstAlive() → {Any}

Call this function to retrieve the first object with alive === true in the group. This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

Returns:
Any -

The first alive child, or null if none found.

Inherited From:
Source - core/Group.js, line 1548

getFirstDead() → {Any}

Call this function to retrieve the first object with alive === false in the group. This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

Returns:
Any -

The first dead child, or null if none found.

Inherited From:
Source - core/Group.js, line 1561

getFirstExists(state) → {Any}

Call this function to retrieve the first object with exists == (the given state) in the Group.

Parameters:
Name Type Description
state boolean

True or false.

Returns:
Any -

The first child, or null if none found.

Inherited From:
Source - core/Group.js, line 1530

getIndex(child) → {number}

Get the index position of the given child in this Group. This should always match the childs z property.

Parameters:
Name Type Description
child *

The child to get the index for.

Returns:
number -

The index of the child or -1 if it's not a member of this Group.

Inherited From:
Source - core/Group.js, line 613

getLocalBounds() → {PIXI.Rectangle}

Retrieves the non-global local bounds of the displayObjectContainer as a rectangle. The calculation takes all visible children into consideration.

Returns:

The rectangular bounding area

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 362

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.

Returns:
Any -

A random child of this Group.

Inherited From:
Source - core/Group.js, line 1628

getTop() → {Any}

Returns the child at the top of this Group. The top is the one being displayed (rendered) above every other child.

Returns:
Any -

The child at the top of the Group.

Inherited From:
Source - core/Group.js, line 1574

hasProperty(child, key) → {boolean}

Checks if the child has the given property. Will scan up to 4 levels deep only.

Parameters:
Name Type Description
child *

The child to check for the existance of the property on.

key array

An array of strings that make up the property.

Returns:
boolean -

True if the child has the property, otherwise false.

Inherited From:
Source - core/Group.js, line 662

iterate(key, value, returnType, callback, callbackContext) → {any}

Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match. Matched children can be sent to the optional callback, or simply returned or counted. You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter.

Parameters:
Name Type Argument Default Description
key string

The child property to check, i.e. 'exists', 'alive', 'health'

value any

If child.key === this value it will be considered a match. Note that a strict comparison is used.

returnType number

How to return the data from this method. Either Phaser.Group.RETURN_NONE, Phaser.Group.RETURN_TOTAL or Phaser.Group.RETURN_CHILD.

callback function <optional>
null

Optional function that will be called on each matching child. Each child of the Group will be passed to it as its first parameter.

callbackContext Object <optional>

The context in which the function should be called (usually 'this').

Returns:
any -

Returns either a numeric total (if RETURN_TOTAL was specified) or the child object.

Inherited From:
Source - core/Group.js, line 1472

mousedown(interactionData)

A callback that is used when the user clicks the mouse's left button down over the sprite

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 258

mouseout(interactionData)

A callback that is used when the users mouse leaves the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 245

mouseover(interactionData)

A callback that is used when the users mouse rolls over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 239

mouseup(interactionData)

A callback that is used when the user releases the mouse's left button that was over the displayObject for this callback to be fired, the mouse's left button must have been pressed down over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 264

mouseupoutside(interactionData)

A callback that is used when the user releases the mouse's left button that was over the displayObject but is no longer over the displayObject for this callback to be fired, the mouse's left button must have been pressed down over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 271

moveDown(child) → {*}

Moves the given child down one place in this Group unless it's already at the top.

Parameters:
Name Type Description
child *

The child to move down in the Group.

Returns:
* -

The child that was moved.

Inherited From:
Source - core/Group.js, line 555

moveUp(child) → {*}

Moves the given child up one place in this Group unless it's already at the top.

Parameters:
Name Type Description
child *

The child to move up in the Group.

Returns:
* -

The child that was moved.

Inherited From:
Source - core/Group.js, line 531

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.

Inherited From:
Source - core/Group.js, line 969

next() → {*}

Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.

Returns:
* -

The child the cursor now points to.

Inherited From:
Source - core/Group.js, line 424

<internal> postUpdate()

The core postUpdate - as called by World.

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1188

<internal> preUpdate()

The core preUpdate - as called by World.

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1148

previous() → {*}

Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object.

Returns:
* -

The child the cursor now points to.

Inherited From:
Source - core/Group.js, line 451

remove(child, destroy, silent) → {boolean}

Removes the given child from this Group. This will dispatch an onRemovedFromGroup event from the child (if it has one), reset the Group cursor and optionally destroy the child.

Parameters:
Name Type Argument Default Description
child Any

The child to remove.

destroy boolean <optional>
false

You can optionally call destroy on the child that was removed.

silent boolean <optional>
false

If the silent parameter is true the child will not dispatch the onRemovedFromGroup event.

Returns:
boolean -

true if the child was removed from this Group, otherwise false.

Inherited From:
Source - core/Group.js, line 1650

removeAll(destroy, silent)

Removes all children from this Group, setting the parent property of the children to null. The Group container remains on the display list.

Parameters:
Name Type Argument Default Description
destroy boolean <optional>
false

You can optionally call destroy on each child that is removed.

silent boolean <optional>
false

If the silent parameter is true the children will not dispatch their onRemovedFromGroup events.

Inherited From:
Source - core/Group.js, line 1693

removeBetween(startIndex, endIndex, destroy, silent)

Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.

Parameters:
Name Type Argument Default Description
startIndex number

The index to start removing children from.

endIndex number <optional>

The index to stop removing children at. Must be higher than startIndex. If undefined this method will remove all children between startIndex and the end of the Group.

destroy boolean <optional>
false

You can optionally call destroy on the child that was removed.

silent boolean <optional>
false

If the silent parameter is true the children will not dispatch their onRemovedFromGroup events.

Inherited From:
Source - core/Group.js, line 1731

removeChild(child) → {PIXI.DisplayObject}

Removes a child from the container.

Parameters:
Name Type Description
child PIXI.DisplayObject

The DisplayObject to remove

Returns:

The child that was removed.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 210

removeChildAt(index) → {PIXI.DisplayObject}

Removes a child from the specified index position.

Parameters:
Name Type Description
index Number

The index to get the child from

Returns:

The child that was removed.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 225

removeChildren(beginIndex, endIndex)

Removes all children from this container that are within the begin and end indexes.

Parameters:
Name Type Description
beginIndex Number

The beginning position. Default value is 0.

endIndex Number

The ending position. Default value is size of the container.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 243

removeStageReference()

Removes the current stage reference from the container and all of its children.

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 404

replace(oldChild, newChild) → {*}

Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.

Parameters:
Name Type Description
oldChild *

The child in this Group that will be replaced.

newChild *

The child to be inserted into this Group.

Returns:
* -

Returns the oldChild that was replaced within this Group.

Inherited From:
Source - core/Group.js, line 626

resetCursor(index) → {*}

Sets the Group cursor to the first object in the Group. If the optional index parameter is given it sets the cursor to the object at that index instead.

Parameters:
Name Type Argument Default Description
index number <optional>
0

Set the cursor to point to a specific index.

Returns:
* -

The child the cursor now points to.

Inherited From:
Source - core/Group.js, line 399

resize()

Resize.

Source - core/FlexLayer.js, line 93

reverse()

Reverses all children in this Group. Note that this does not propagate, only direct children are re-ordered.

Inherited From:
Source - core/Group.js, line 601

rightclick(interactionData)

A callback that is used when the users clicks on the displayObject with their mouse's right button

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 279

rightdown(interactionData)

A callback that is used when the user clicks the mouse's right button down over the sprite

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 285

rightup(interactionData)

A callback that is used when the user releases the mouse's right button that was over the displayObject for this callback to be fired the mouse's right button must have been pressed down over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 291

rightupoutside(interactionData)

A callback that is used when the user releases the mouse's right button that was over the displayObject but is no longer over the displayObject for this callback to be fired, the mouse's right button must have been pressed down over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 298

sendToBack(child) → {*}

Sends the given child to the bottom of this Group so it renders below all other children.

Parameters:
Name Type Description
child *

The child to send to the bottom of this Group.

Returns:
* -

The child that was moved.

Inherited From:
Source - core/Group.js, line 512

set(child, key, value, checkAlive, checkVisible, operation, force) → {boolean}

This function allows you to quickly set a property on a single child of this Group to a new value. The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.

Parameters:
Name Type Argument Default Description
child Phaser.Sprite

The child to set the property on.

key string

The property, as a string, to be set. For example: 'body.velocity.x'

value *

The value that will be set.

checkAlive boolean <optional>
false

If set then the child will only be updated if alive=true.

checkVisible boolean <optional>
false

If set then the child will only be updated if visible=true.

operation number <optional>
0

Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

force boolean <optional>
false

If force is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.

Returns:
boolean -

True if the property was set, false if not.

Inherited From:
Source - core/Group.js, line 800

setAll(key, value, checkAlive, checkVisible, operation, force)

This function allows you to quickly set the same property across all children of this Group to a new value. This call doesn't descend down children, so if you have a Group inside of this Group, the property will be set on the Group but not its children. If you need that ability please see Group.setAllChildren.

The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.

Parameters:
Name Type Argument Default Description
key string

The property, as a string, to be set. For example: 'body.velocity.x'

value *

The value that will be set.

checkAlive boolean <optional>
false

If set then only children with alive=true will be updated. This includes any Groups that are children.

checkVisible boolean <optional>
false

If set then only children with visible=true will be updated. This includes any Groups that are children.

operation number <optional>
0

Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

force boolean <optional>
false

If force is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.

Inherited From:
Source - core/Group.js, line 830

setAllChildren(key, value, checkAlive, checkVisible, operation, force)

This function allows you to quickly set the same property across all children of this Group, and any child Groups, to a new value.

If this Group contains other Groups then the same property is set across their children as well, iterating down until it reaches the bottom. Unlike with Group.setAll the property is NOT set on child Groups itself.

The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.

Parameters:
Name Type Argument Default Description
key string

The property, as a string, to be set. For example: 'body.velocity.x'

value *

The value that will be set.

checkAlive boolean <optional>
false

If set then only children with alive=true will be updated. This includes any Groups that are children.

checkVisible boolean <optional>
false

If set then only children with visible=true will be updated. This includes any Groups that are children.

operation number <optional>
0

Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

force boolean <optional>
false

If force is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.

Inherited From:
Source - core/Group.js, line 864

setChildIndex(child, index)

Changes the position of an existing child in the display object container

Parameters:
Name Type Description
child PIXI.DisplayObject

The child DisplayObject instance for which you want to change the index number

index Number

The resulting index number for the child display object

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 175

setProperty(child, key, value, operation, force) → {boolean}

Sets a property to the given value on the child. The operation parameter controls how the value is set. Operation 0 means set the existing value to the given value, or if force is false create a new property with the given value. 1 will add the given value to the value already present. 2 will subtract the given value from the value already present. 3 will multiply the value already present by the given value. 4 will divide the value already present by the given value.

Parameters:
Name Type Argument Default Description
child *

The child to set the property value on.

key array

An array of strings that make up the property that will be set.

value *

The value that will be set.

operation number <optional>
0

Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

force boolean <optional>
false

If force is true then the property will be set on the child regardless if it already exists or not. If false and the property doesn't exist, nothing will be set.

Returns:
boolean -

True if the property was set, false if not.

Inherited From:
Source - core/Group.js, line 695

setStageReference(stage)

Sets the containers Stage reference. This is the Stage that this object, and all of its children, is connected to.

Parameters:
Name Type Description
stage PIXI.Stage

the stage that the container will have as its current stage reference

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 386

sort(index, order)

Call this function to sort the group according to a particular value and order. For example to depth sort Sprites for Zelda-style game you might call group.sort('y', Phaser.Group.SORT_ASCENDING) at the bottom of your State.update().

Parameters:
Name Type Argument Default Description
index string <optional>
'z'

The string name of the property you want to sort on. Defaults to the objects z-depth value.

order number <optional>
Phaser.Group.SORT_ASCENDING

The Group constant that defines the sort order. Possible values are Phaser.Group.SORT_ASCENDING and Phaser.Group.SORT_DESCENDING.

Inherited From:
Source - core/Group.js, line 1361

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.

Inherited From:
Source - core/Group.js, line 953

swap(child1, child2)

Swaps the position of two children in this Group. Both children must be in this Group. You cannot swap a child with itself, or swap un-parented children.

Parameters:
Name Type Description
child1 *

The first child to swap.

child2 *

The second child to swap.

Inherited From:
Source - core/Group.js, line 478

swapChildren(child, child2)

Swaps the position of 2 Display Objects within this container.

Parameters:
Name Type Description
child PIXI.DisplayObject

-

child2 PIXI.DisplayObject

-

Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 133

tap(interactionData)

A callback that is used when the users taps on the sprite with their finger basically a touch version of click

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 309

toGlobal(position) → {PIXI.Point}

Calculates the global position of the display object

Parameters:
Name Type Description
position PIXI.Point

The world origin to calculate from

Returns:

A point object representing the position of this object

Inherited From:
Source - pixi/display/DisplayObject.js, line 616

toLocal(position, from) → {PIXI.Point}

Calculates the local position of the display object relative to another point

Parameters:
Name Type Argument Description
position PIXI.Point

The world origin to calculate from

from PIXI.DisplayObject <optional>

The DisplayObject to calculate the global position from

Returns:

A point object representing the position of this object

Inherited From:
Source - pixi/display/DisplayObject.js, line 630

touchend(interactionData)

A callback that is used when the user releases a touch over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 322

touchendoutside(interactionData)

A callback that is used when the user releases the touch that was over the displayObject for this callback to be fired, The touch must have started over the sprite

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 328

touchstart(interactionData)

A callback that is used when the user touches over the displayObject

Parameters:
Name Type Description
interactionData PIXI.InteractionData

-

Inherited From:
Source - pixi/display/DisplayObject.js, line 316

<internal> update()

The core update - as called by World.

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1172

updateCache()

Generates and updates the cached sprite for this object.

Inherited From:
Source - pixi/display/DisplayObject.js, line 606

<internal> updateZ()

Internal method that re-applies all of the childrens Z values.

Inherited From:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 382

xy(index, x, y)

Positions the child found at the given index within this Group to the given x and y coordinates.

Parameters:
Name Type Description
index number

The index of the child in the Group to set the position of.

x number

The new x position of the child.

y number

The new y position of the child.

Inherited From:
Source - core/Group.js, line 579
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Tue Nov 25 2014 00:17:31 GMT-0000 (GMT) using the DocStrap template.