Phaser.Particles.Arcade. Emitter

new Emitter(game, x, y, maxParticles)

Emitter is a lightweight particle emitter that uses Arcade Physics.
It can be used for one-time explosions or for continuous effects like rain and fire.
All it really does is launch Particle objects out at set intervals, and fixes their positions and velocities accordingly.

Parameters:
Name Type Argument Default Description
game Phaser.Game

Current game instance.

x number <optional>
0

The x coordinate within the Emitter that the particles are emitted from.

y number <optional>
0

The y coordinate within the Emitter that the particles are emitted from.

maxParticles number <optional>
50

The total number of particles in this emitter.

Source - particles/arcade/Emitter.js, line 20

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 93

alpha :number

The alpha value of the group container.

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

alphaData :array

An array of the calculated alpha easing data applied to particles with alphaRates > 0.

Source - particles/arcade/Emitter.js, line 115

angle :number

The angle of rotation of the group container, in degrees.

This adjusts the group itself by modifying its local rotation transform.

This has no impact on the rotation/angle properties of the children, but it will update their worldTransform
and on-screen orientation and position.

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

angularDrag :number

The angular drag component of particles launched from the emitter if they are rotating.

Source - particles/arcade/Emitter.js, line 138

area :Phaser.Rectangle

The area of the emitter. Particles can be randomly generated from anywhere within this rectangle.

Source - particles/arcade/Emitter.js, line 57

autoAlpha :boolean

When a new Particle is emitted this controls if it will automatically change alpha. Use Emitter.setAlpha to configure.

Source - particles/arcade/Emitter.js, line 199

autoScale :boolean

When a new Particle is emitted this controls if it will automatically scale in size. Use Emitter.setScale to configure.

Source - particles/arcade/Emitter.js, line 194

blendMode :number

The blendMode as set on the particle when emitted from the Emitter. Defaults to NORMAL. Needs browser capable of supporting canvas blend-modes (most not available in WebGL)

Source - particles/arcade/Emitter.js, line 173

<readonly> bottom :number

Gets the bottom position of the Emitter.

Source - particles/arcade/Emitter.js, line 1026

bounce :Phaser.Point

How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.

Source - particles/arcade/Emitter.js, line 155

cacheAsBitmap :Boolean

Sets if this DisplayObject should be cached as a bitmap.

When invoked it will take a snapshot of the DisplayObject, as it is at that moment, and store it
in a RenderTexture. This is then used whenever this DisplayObject is rendered. It can provide a
performance benefit for complex, but static, DisplayObjects. I.e. those with lots of children.

Cached Bitmaps do not track their parents. If you update a property of this DisplayObject, it will not
re-generate the cached bitmap automatically. To do that you need to call DisplayObject.updateCache.

To remove a cached bitmap, set this property to null.

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

cameraOffset :Phaser.Point

If this object is fixedToCamera then this stores the x/y position offset relative to the top-left of the camera view.
If the parent of this Group is also fixedToCamera then the offset here is in addition to that and should typically be disabled.

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

centerX :number

The center x coordinate of this Group.

It is derived by calling getBounds, calculating the Groups dimensions based on its
visible children.

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

centerY :number

The center y coordinate of this Group.

It is derived by calling getBounds, calculating the Groups dimensions based on its
visible children.

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

<readonly> children :Array.<DisplayObject>

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

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

classType :function

The type of objects that will be created when using create or createMultiple.

It should extend either Sprite or Image and accept the same constructor arguments: (game, x, y, key, frame).

Inherited From:
Default Value:
Source - core/Group.js, line 129

cursor :DisplayObject

The current display object that the group cursor is pointing to, if any. (Can be set manually.)

The cursor is a way to iterate through the children in a Group using next and previous.

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

<readonly> cursorIndex :integer

The current index of the Group cursor. Advance it with Group.next.

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

emitX :number

The point the particles are emitted from.
Emitter.x and Emitter.y control the containers location, which updates all current particles
Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.

Source - particles/arcade/Emitter.js, line 181

emitY :number

The point the particles are emitted from.
Emitter.x and Emitter.y control the containers location, which updates all current particles
Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.

Source - particles/arcade/Emitter.js, line 189

enableBody :boolean

If true all Sprites created by, or added to this group, will have a physics body enabled on them.

If there are children already in the Group at the time you set this property, they are not changed.

The default body type is controlled with physicsBodyType.

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

enableBodyDebug :boolean

If true when a physics body is created (via enableBody) it will create a physics debug object as well.

This only works for P2 bodies.

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

exists :boolean

If exists is false the group will be excluded from collision checks and filters such as forEachExists. The group will not call preUpdate and postUpdate on its children and the children will not receive physics updates or camera/world boundary checks. The group will still be visible and will still call update on its children.

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

filterArea :Rectangle

The rectangular area used by filters when rendering a shader for this DisplayObject.

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

filters :Array

Sets the filters for this DisplayObject. This is a WebGL only feature, and is ignored by the Canvas
Renderer. A filter is a shader applied to this DisplayObject. You can modify the placement of the filter
using DisplayObject.filterArea.

To remove filters, set this property to null.

Note: You cannot have a filter set, and a MULTIPLY Blend Mode active, at the same time. Setting a
filter will reset this DisplayObjects blend mode to NORMAL.

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

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

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

frequency :number

How often a particle is emitted in ms (if emitter is started with Explode === false).

Default Value:
  • 100
Source - particles/arcade/Emitter.js, line 144

<internal> game :Phaser.Game

A reference to the currently running Game.

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

gravity :Phaser.Point

Sets the body.gravity of each particle sprite to this on launch.

Source - particles/arcade/Emitter.js, line 121

hash :array

The hash array is an array belonging to this Group into which you can add any of its children via Group.addToHash and Group.removeFromHash.

Only children of this Group can be added to and removed from the hash.

This hash is used automatically by Phaser Arcade Physics in order to perform non z-index based destructive sorting.
However if you don't use Arcade Physics, or this isn't a physics enabled Group, then you can use the hash to perform your own
sorting and filtering of Group children without touching their z-index (and therefore display draw order)

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

height :number

Gets or sets the height of the Emitter. This is the region in which a particle can be emitted.

Source - particles/arcade/Emitter.js, line 939

hitArea :Rectangle|Circle|Ellipse|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:
  • Rectangle | Circle | Ellipse | Polygon
Inherited From:
Source - pixi/display/DisplayObject.js, line 89

id :number

Gets the internal ID that represents this emitter.

Source - particles/arcade/Emitter.js, line 913

ignoreChildInput :Boolean

If ignoreChildInput is false it will allow this objects children to be considered as valid for Input events.

If this property is true then the children will not be considered as valid for Input events.

Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down.

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

ignoreDestroy :boolean

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

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

inputEnableChildren :boolean

A Group with inputEnableChildren set to true will automatically call inputEnabled = true
on any children added to, or created by, this Group.

If there are children already in the Group at the time you set this property, they are not changed.

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

<readonly> left :number

Gets the left position of the Emitter.

Source - particles/arcade/Emitter.js, line 987

<readonly> length :integer

Total number of children in this group, regardless of exists/alive status.

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

lifespan :number

How long each particle lives once it is emitted in ms. Default is 2 seconds. Set lifespan to 'zero' for particles to live forever.

Default Value:
  • 2000
Source - particles/arcade/Emitter.js, line 150

mask :PIXIGraphics

Sets a mask for this DisplayObject. A mask is an instance of a Graphics object.
When applied it limits the visible area of this DisplayObject to the shape of the mask.
Under a Canvas renderer it uses shape clipping. Under a WebGL renderer it uses a Stencil Buffer.
To remove a mask, set this property to null.

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

maxParticleAlpha :number

The maximum possible alpha value of a particle.

Default Value:
  • 1
Source - particles/arcade/Emitter.js, line 110

maxParticles :number

The total number of particles in this emitter.

Source - particles/arcade/Emitter.js, line 26

maxParticleScale :number

The maximum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see maxParticleScaleX.

Default Value:
  • 1
Source - particles/arcade/Emitter.js, line 81

maxParticleSpeed :Phaser.Point

The maximum possible velocity of a particle.

Source - particles/arcade/Emitter.js, line 69

maxRotation :number

The maximum possible angular velocity of a particle.

Default Value:
  • 360
Source - particles/arcade/Emitter.js, line 98

minParticleAlpha :number

The minimum possible alpha value of a particle.

Default Value:
  • 1
Source - particles/arcade/Emitter.js, line 104

minParticleScale :number

The minimum possible scale of a particle. This is applied to the X and Y axis. If you need to control each axis see minParticleScaleX.

Default Value:
  • 1
Source - particles/arcade/Emitter.js, line 75

minParticleSpeed :Phaser.Point

The minimum possible velocity of a particle.

Source - particles/arcade/Emitter.js, line 63

minRotation :number

The minimum possible angular velocity of a particle.

Source - particles/arcade/Emitter.js, line 92

name :string

A handy string name for this emitter. Can be set to anything.

Source - particles/arcade/Emitter.js, line 39

on :boolean

Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.

Source - particles/arcade/Emitter.js, line 161

onChildInputDown :Phaser.Signal

This Signal is dispatched whenever a child of this Group emits an onInputDown signal as a result
of having been interacted with by a Pointer. You can bind functions to this Signal instead of to
every child Sprite.

This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and
a reference to the Pointer that caused it.

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

onChildInputOut :Phaser.Signal

This Signal is dispatched whenever a child of this Group emits an onInputOut signal as a result
of having been interacted with by a Pointer. You can bind functions to this Signal instead of to
every child Sprite.

This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and
a reference to the Pointer that caused it.

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

onChildInputOver :Phaser.Signal

This Signal is dispatched whenever a child of this Group emits an onInputOver signal as a result
of having been interacted with by a Pointer. You can bind functions to this Signal instead of to
every child Sprite.

This Signal is sent 2 arguments: A reference to the Sprite that triggered the signal, and
a reference to the Pointer that caused it.

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

onChildInputUp :Phaser.Signal

This Signal is dispatched whenever a child of this Group emits an onInputUp signal as a result
of having been interacted with by a Pointer. You can bind functions to this Signal instead of to
every child Sprite.

This Signal is sent 3 arguments: A reference to the Sprite that triggered the signal,
a reference to the Pointer that caused it, and a boolean value isOver that tells you if the Pointer
is still over the Sprite or not.

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

onDestroy :Phaser.Signal

This signal is dispatched when the group is destroyed.

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

<readonly> parent :PIXIDisplayObjectContainer

The parent DisplayObjectContainer that this DisplayObject is a child of.
All DisplayObjects must belong to a parent in order to be rendered.
The root parent is the Stage object. This property is set automatically when the
DisplayObject is added to, or removed from, a DisplayObjectContainer.

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

particleAnchor :Phaser.Point

When a particle is created its anchor will be set to match this Point object (defaults to x/y: 0.5 to aid in rotation)

Source - particles/arcade/Emitter.js, line 167

particleBringToTop :boolean

If this is true then when the Particle is emitted it will be bought to the top of the Emitters display list.

Source - particles/arcade/Emitter.js, line 205

particleClass :function

For emitting your own particle class types. They must extend Phaser.Particle.

Source - particles/arcade/Emitter.js, line 127

particleDrag :Phaser.Point

The X and Y drag component of particles launched from the emitter.

Source - particles/arcade/Emitter.js, line 132

particleSendToBack :boolean

If this is true then when the Particle is emitted it will be sent to the back of the Emitters display list.

Source - particles/arcade/Emitter.js, line 211

pendingDestroy :boolean

A Group is that has pendingDestroy set to true is flagged to have its destroy method
called on the next logic update.
You can set it directly to flag the Group to be destroyed on its next update.

This is extremely useful if you wish to destroy a Group from within one of its own callbacks
or a callback of one of its children.

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

physicsBodyType :integer

If enableBody is true this is the type of physics body that is created on new Sprites.

The valid values are Phaser.Physics.ARCADE, Phaser.Physics.P2JS, Phaser.Physics.NINJA, etc.

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

physicsSortDirection :integer

If this Group contains Arcade Physics Sprites you can set a custom sort direction via this property.

It should be set to one of the Phaser.Physics.Arcade sort direction constants:

Phaser.Physics.Arcade.SORT_NONE
Phaser.Physics.Arcade.LEFT_RIGHT
Phaser.Physics.Arcade.RIGHT_LEFT
Phaser.Physics.Arcade.TOP_BOTTOM
Phaser.Physics.Arcade.BOTTOM_TOP

If set to null the Group will use whatever Phaser.Physics.Arcade.sortDirection is set to. This is the default behavior.

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

<readonly> physicsType :number

The const physics body type of this object.

Source - particles/arcade/Emitter.js, line 51

pivot :PIXIPoint

The pivot point of this DisplayObject that it rotates around. The values are expressed
in pixel values.

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

position :PIXIPoint

The coordinates, in pixels, of this DisplayObject, relative to its parent container.

The value of this property does not reflect any positioning happening further up the display list.
To obtain that value please see the worldPosition property.

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

renderable :Boolean

Should this DisplayObject be rendered by the renderer? An object with a renderable value of
false is skipped during the render pass.

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

Gets the right position of the Emitter.

Source - particles/arcade/Emitter.js, line 1000

rotation :number

The angle of rotation of the group container, in radians.

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.

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

scale :PIXIPoint

The scale of this DisplayObject. A scale of 1:1 represents the DisplayObject
at its default size. A value of 0.5 would scale this DisplayObject by half, and so on.

The value of this property does not reflect any scaling happening further up the display list.
To obtain that value please see the worldScale property.

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

scaleData :array

An array of the calculated scale easing data applied to particles with scaleRates > 0.

Source - particles/arcade/Emitter.js, line 86

<readonly> top :number

Gets the top position of the Emitter.

Source - particles/arcade/Emitter.js, line 1013

<readonly> total :integer

Total number of existing children in the group.

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

<internal> type :number

Internal Phaser Type value.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - particles/arcade/Emitter.js, line 45

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 3008

width :number

Gets or sets the width of the Emitter. This is the region in which a particle can be emitted.

Source - particles/arcade/Emitter.js, line 923

<readonly> worldAlpha :Number

The multiplied alpha value of this DisplayObject. A value of 1 is fully opaque. A value of 0 is transparent.
This value is the calculated total, based on the alpha values of all parents of this DisplayObjects
in the display list.

To obtain, and set, the local alpha value, see the alpha property.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

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

<readonly> worldPosition :PIXIPoint

The coordinates, in pixels, of this DisplayObject within the world.

This property contains the calculated total, based on the positions of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

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

<readonly> worldRotation :Number

The rotation, in radians, of this DisplayObject.

This property contains the calculated total, based on the rotations of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

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

<readonly> worldScale :PIXIPoint

The global scale of this DisplayObject.

This property contains the calculated total, based on the scales of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

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

<readonly> worldTransform :PIXIMatrix

The current transform of this DisplayObject.

This property contains the calculated total, based on the transforms of all parents of this
DisplayObject in the display list.

Note: This property is only updated at the end of the updateTransform call, once per render. Until
that happens this property will contain values based on the previous frame. Be mindful of this if
accessing this property outside of the normal game flow, i.e. from an asynchronous event callback.

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

worldVisible :Boolean

Indicates if this DisplayObject is visible, based on it, and all of its parents, visible property values.

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

x :number

Gets or sets the x position of the Emitter.

Source - particles/arcade/Emitter.js, line 955

y :number

Gets or sets the y position of the Emitter.

Source - particles/arcade/Emitter.js, line 971

<readonly> z :integer

The z-depth value of this object within its parent container/Group - the World is a Group as well.
This value must be unique for each child in a Group.

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

Methods

add(child, silent, index) → {DisplayObject}

Adds an existing object as the top child in this group.

The child is automatically added to the top of the group, and is displayed above every previous child.

Or if the optional index is specified, the child is added at the location specified by the index value,
this allows you to control child ordering.

If the child was already in this Group, it is simply returned, and nothing else happens to it.

If Group.enableBody is set, then a physics body will be created on the object, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the object, so long as one does not already exist.

Use addAt to control where a child is added. Use create to create and add a new child.

Parameters:
Name Type Argument Default Description
child DisplayObject

The display object to add as a child.

silent boolean <optional>
false

If true the child will not dispatch the onAddedToGroup event.

index integer <optional>

The index within the group to insert the child to. Where 0 is the bottom of the Group.

Returns:

The child that was added to the group.

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

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 for each child.

Parameters:
Name Type Argument 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 <optional>

If true the property will only be changed if the child is alive.

checkVisible boolean <optional>

If true the property will only be changed if the child is visible.

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

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

Adds an existing object to this group.

The child is added to the group at the location specified by the index value, this allows you to control child ordering.

If Group.enableBody is set, then a physics body will be created on the object, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the object, so long as one does not already exist.

Parameters:
Name Type Argument Default Description
child DisplayObject

The display object to add as a child.

index integer <optional>
0

The index within the group to insert the child to.

silent boolean <optional>
false

If 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 417

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 42

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 55

addMultiple(children, silent) → {Array.<DisplayObject>|Phaser.Group}

Adds an array of existing Display Objects to this Group.

The Display Objects are automatically added to the top of this Group, and will render on-top of everything already in this Group.

As well as an array you can also pass another Group as the first argument. In this case all of the children from that
Group will be removed from it and added into this Group.

If Group.enableBody is set, then a physics body will be created on the objects, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the objects, so long as one does not already exist.

Parameters:
Name Type Argument Default Description
children Array.<DisplayObject> | Phaser.Group

An array of display objects or a Phaser.Group. If a Group is given then all children will be moved from it.

silent boolean <optional>
false

If true the children will not dispatch the onAddedToGroup event.

Returns:

The array of children or Group of children that were added to this Group.

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

addToHash(child) → {boolean}

Adds a child of this Group into the hash array.
This call will return false if the child is not a child of this Group, or is already in the hash.

Parameters:
Name Type Description
child DisplayObject

The display object to add to this Groups hash. Must be a member of this Group already and not present in the hash.

Returns:
boolean -

True if the child was successfully added to the hash, otherwise false.

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

align(width, height, cellWidth, cellHeight, position, offset) → {boolean}

This method iterates through all children in the Group (regardless if they are visible or exist)
and then changes their position so they are arranged in a Grid formation. Children must have
the alignTo method in order to be positioned by this call. All default Phaser Game Objects have
this.

The grid dimensions are determined by the first four arguments. The width and height arguments
relate to the width and height of the grid respectively.

For example if the Group had 100 children in it:

Group.align(10, 10, 32, 32)

This will align all of the children into a grid formation of 10x10, using 32 pixels per
grid cell. If you want a wider grid, you could do:

Group.align(25, 4, 32, 32)

This will align the children into a grid of 25x4, again using 32 pixels per grid cell.

You can choose to set either the width or height value to -1. Doing so tells the method
to keep on aligning children until there are no children left. For example if this Group had
48 children in it, the following:

Group.align(-1, 8, 32, 32)

... will align the children so that there are 8 children vertically (the second argument),
and each row will contain 6 sprites, except the last one, which will contain 5 (totaling 48)

You can also do:

Group.align(10, -1, 32, 32)

In this case it will create a grid 10 wide, and as tall as it needs to be in order to fit
all of the children in.

The position property allows you to control where in each grid cell the child is positioned.
This is a constant and can be one of Phaser.TOP_LEFT (default), Phaser.TOP_CENTER,
Phaser.TOP_RIGHT, Phaser.LEFT_CENTER, Phaser.CENTER, Phaser.RIGHT_CENTER,
Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER or Phaser.BOTTOM_RIGHT.

The final argument; offset lets you start the alignment from a specific child index.

Parameters:
Name Type Argument Default Description
width integer

The width of the grid in items (not pixels). Set to -1 for a dynamic width. If -1 then you must set an explicit height value.

height integer

The height of the grid in items (not pixels). Set to -1 for a dynamic height. If -1 then you must set an explicit width value.

cellWidth integer

The width of each grid cell, in pixels.

cellHeight integer

The height of each grid cell, in pixels.

position integer <optional>

The position constant. One of Phaser.TOP_LEFT (default), Phaser.TOP_CENTER, Phaser.TOP_RIGHT, Phaser.LEFT_CENTER, Phaser.CENTER, Phaser.RIGHT_CENTER, Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER or Phaser.BOTTOM_RIGHT.

offset integer <optional>
0

Optional index to start the alignment from. Defaults to zero, the first child in the Group, but can be set to any valid child index value.

Returns:
boolean -

True if the Group children were aligned, otherwise false.

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

alignIn(container, position, offsetX, offsetY) → {Phaser.Group}

Aligns this Group within another Game Object, or Rectangle, known as the
'container', to one of 9 possible positions.

The container must be a Game Object, or Phaser.Rectangle object. This can include properties
such as World.bounds or Camera.view, for aligning Groups within the world
and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText,
TileSprites or Buttons.

Please note that aligning a Group to another Game Object does not make it a child of
the container. It simply modifies its position coordinates so it aligns with it.

The position constants you can use are:

Phaser.TOP_LEFT, Phaser.TOP_CENTER, Phaser.TOP_RIGHT, Phaser.LEFT_CENTER,
Phaser.CENTER, Phaser.RIGHT_CENTER, Phaser.BOTTOM_LEFT,
Phaser.BOTTOM_CENTER and Phaser.BOTTOM_RIGHT.

Groups are placed in such a way that their bounds align with the
container, taking into consideration rotation and scale of its children.
This allows you to neatly align Groups, irrespective of their position value.

The optional offsetX and offsetY arguments allow you to apply extra spacing to the final
aligned position of the Group. For example:

group.alignIn(background, Phaser.BOTTOM_RIGHT, -20, -20)

Would align the group to the bottom-right, but moved 20 pixels in from the corner.
Think of the offsets as applying an adjustment to the containers bounds before the alignment takes place.
So providing a negative offset will 'shrink' the container bounds by that amount, and providing a positive
one expands it.

Parameters:
Name Type Argument Default Description
container Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite

The Game Object or Rectangle with which to align this Group to. Can also include properties such as World.bounds or Camera.view.

position integer <optional>

The position constant. One of Phaser.TOP_LEFT (default), Phaser.TOP_CENTER, Phaser.TOP_RIGHT, Phaser.LEFT_CENTER, Phaser.CENTER, Phaser.RIGHT_CENTER, Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER or Phaser.BOTTOM_RIGHT.

offsetX integer <optional>
0

A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.

offsetY integer <optional>
0

A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.

Returns:

This Group.

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

alignTo(parent, position, offsetX, offsetY) → {Phaser.Group}

Aligns this Group to the side of another Game Object, or Rectangle, known as the
'parent', in one of 11 possible positions.

The parent must be a Game Object, or Phaser.Rectangle object. This can include properties
such as World.bounds or Camera.view, for aligning Groups within the world
and camera bounds. Or it can include other Sprites, Images, Text objects, BitmapText,
TileSprites or Buttons.

Please note that aligning a Group to another Game Object does not make it a child of
the parent. It simply modifies its position coordinates so it aligns with it.

The position constants you can use are:

Phaser.TOP_LEFT (default), Phaser.TOP_CENTER, Phaser.TOP_RIGHT, Phaser.LEFT_TOP,
Phaser.LEFT_CENTER, Phaser.LEFT_BOTTOM, Phaser.RIGHT_TOP, Phaser.RIGHT_CENTER,
Phaser.RIGHT_BOTTOM, Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER
and Phaser.BOTTOM_RIGHT.

Groups are placed in such a way that their bounds align with the
parent, taking into consideration rotation and scale of the children.
This allows you to neatly align Groups, irrespective of their position value.

The optional offsetX and offsetY arguments allow you to apply extra spacing to the final
aligned position of the Group. For example:

group.alignTo(background, Phaser.BOTTOM_RIGHT, -20, -20)

Would align the group to the bottom-right, but moved 20 pixels in from the corner.
Think of the offsets as applying an adjustment to the parents bounds before the alignment takes place.
So providing a negative offset will 'shrink' the parent bounds by that amount, and providing a positive
one expands it.

Parameters:
Name Type Argument Default Description
parent Phaser.Rectangle | Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Button | Phaser.Graphics | Phaser.TileSprite

The Game Object or Rectangle with which to align this Group to. Can also include properties such as World.bounds or Camera.view.

position integer <optional>

The position constant. One of Phaser.TOP_LEFT, Phaser.TOP_CENTER, Phaser.TOP_RIGHT, Phaser.LEFT_TOP, Phaser.LEFT_CENTER, Phaser.LEFT_BOTTOM, Phaser.RIGHT_TOP, Phaser.RIGHT_CENTER, Phaser.RIGHT_BOTTOM, Phaser.BOTTOM_LEFT, Phaser.BOTTOM_CENTER or Phaser.BOTTOM_RIGHT.

offsetX integer <optional>
0

A horizontal adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.

offsetY integer <optional>
0

A vertical adjustment of the Containers bounds, applied to the aligned position of the Game Object. Use a negative value to shrink the bounds, positive to increase it.

Returns:

This Group.

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

<internal> 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:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1931

at(object) → {Phaser.Particles.Arcade.Emitter}

Change the emitters center to match the center of any object with a center property, such as a Sprite.
If the object doesn't have a center property it will be set to object.x + object.width / 2

Parameters:
Name Type Description
object object | Phaser.Sprite | Phaser.Image | Phaser.TileSprite | Phaser.Text | PIXI.DisplayObject

The object that you wish to match the center with.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 888

bringToTop(child) → {any}

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

Parameters:
Name Type Description
child any

The child to bring to the top of this group.

Returns:
any -

The child that was moved.

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

callAll(method, context, args)

Calls a function, specified by name, on all on children.

The function is called for all children regardless if they are dead or alive (see callAllExists for different options).
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

Name of the function on the child to call. Deep property lookup is supported.

context string <optional>
null

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

args any <repeatable>

Additional parameters that will be passed to the method.

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

callAllExists(callback, existsValue, parameter)

Calls a function, specified by name, on all children in the group who exist (or do not exist).

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 string

Name of the function on the children to call.

existsValue boolean

Only children with exists=existsValue will be called.

parameter any <repeatable>

Additional parameters that will be passed to the callback.

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

<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 integer

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 1487

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

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 any

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 1352

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

Checks a property for the given value on the child.

Parameters:
Name Type Argument Default Description
child any

The child to check the property value on.

key array

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

value any

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 1216

contains(child) → {Boolean}

Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.

Parameters:
Name Type Description
child PIXI.DisplayObject

-

Returns:
Boolean -
Inherited From:
Source - pixi/display/DisplayObjectContainer.js, line 449

countDead() → {integer}

Get the number of dead children in this group.

Returns:
integer -

The number of children flagged as dead.

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

countLiving() → {integer}

Get the number of living children in this group.

Returns:
integer -

The number of children flagged as alive.

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

create(x, y, key, frame, exists, index) → {DisplayObject}

Creates a new Phaser.Sprite object and adds it to the top of this group.

Use classType to change the type of object created.

The child is automatically added to the top of the group, and is displayed above every previous child.

Or if the optional index is specified, the child is added at the location specified by the index value,
this allows you to control child ordering.

If Group.enableBody is set, then a physics body will be created on the object, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the object, so long as one does not already exist.

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 | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

exists boolean <optional>
true

The default exists state of the Sprite.

index integer <optional>

The index within the group to insert the child to. Where 0 is the bottom of the Group.

Returns:

The child that was created: will be a Phaser.Sprite unless #classType has been changed.

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

createMultiple(quantity, key, frame, exists) → {array}

Creates multiple Phaser.Sprite objects and adds them to the top of this Group.

This method is useful if you need to quickly generate a pool of sprites, such as bullets.

Use classType to change the type of object created.

You can provide an array as the key and / or frame arguments. When you do this
it will create quantity Sprites for every key (and frame) in the arrays.

For example:

createMultiple(25, ['ball', 'carrot'])

In the above code there are 2 keys (ball and carrot) which means that 50 sprites will be
created in total, 25 of each. You can also have the frame as an array:

createMultiple(5, 'bricks', [0, 1, 2, 3])

In the above there is one key (bricks), which is a sprite sheet. The frames array tells
this method to use frames 0, 1, 2 and 3. So in total it will create 20 sprites, because
the quantity was set to 5, so that is 5 brick sprites of frame 0, 5 brick sprites with
frame 1, and so on.

If you set both the key and frame arguments to be arrays then understand it will create
a total quantity of sprites equal to the size of both arrays times each other. I.e.:

createMultiple(20, ['diamonds', 'balls'], [0, 1, 2])

The above will create 20 'diamonds' of frame 0, 20 with frame 1 and 20 with frame 2.
It will then create 20 'balls' of frame 0, 20 with frame 1 and 20 with frame 2.
In total it will have created 120 sprites.

By default the Sprites will have their exists property set to false, and they will be
positioned at 0x0, relative to the Group.x / y values.

If Group.enableBody is set, then a physics body will be created on the objects, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the objects, so long as one does not already exist.

Parameters:
Name Type Argument Default Description
quantity integer

The number of Sprites to create.

key string | array

The Cache key of the image that the Sprites will use. Or an Array of keys. See the description for details on how the quantity applies when arrays are used.

frame integer | string | array <optional>
0

If the Sprite image contains multiple frames you can specify which one to use here. Or an Array of frames. See the description for details on how the quantity applies when arrays are used.

exists boolean <optional>
false

The default exists state of the Sprite.

Returns:
array -

An array containing all of the Sprites that were created.

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

customSort(sortHandler, context)

Sort the children in the group according to custom sort function.

The sortHandler is provided the 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 Argument Description
sortHandler function

The custom sort function.

context object <optional>

The context in which the sortHandler is called.

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

<internal> 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:
Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - core/Group.js, line 1963

destroy()

Destroys this Emitter, all associated child Particles and then removes itself from the Particle Manager.

Source - particles/arcade/Emitter.js, line 707

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 for each child.

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 1436

emitParticle(x, y, key, frame) → {boolean}

This function is used internally to emit the next particle in the queue.

However it can also be called externally to emit a particle.

When called externally you can use the arguments to override any defaults the Emitter has set.

Parameters:
Name Type Argument Description
x number <optional>

The x coordinate to emit the particle from. If null or undefined it will use Emitter.emitX or if the Emitter has a width > 1 a random value between Emitter.left and Emitter.right.

y number <optional>

The y coordinate to emit the particle from. If null or undefined it will use Emitter.emitY or if the Emitter has a height > 1 a random value between Emitter.top and Emitter.bottom.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Particle during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Particle is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

Returns:
boolean -

True if a particle was emitted, otherwise false.

Source - particles/arcade/Emitter.js, line 579

explode(lifespan, quantity) → {Phaser.Particles.Arcade.Emitter}

Call this function to emit the given quantity of particles at all once (an explosion)

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

How long each particle lives once emitted in ms. 0 = forever.

quantity number <optional>
this.maxParticles

How many particles to launch.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 446

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

Find children matching a certain 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 true, only existing can be selected; otherwise all children can be selected and will be passed to the predicate.

Returns:

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

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

flow(lifespan, frequency, quantity, total, immediate) → {Phaser.Particles.Arcade.Emitter}

Call this function to start emitting a flow of particles at the given frequency.
It will carry on going until the total given is reached.
Each time the flow is run the quantity number of particles will be emitted together.
If you set the total to be 20 and quantity to be 5 then flow will emit 4 times in total (4 x 5 = 20 total)
If you set the total to be -1 then no quantity cap is used and it will keep emitting.

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

How long each particle lives once emitted in ms. 0 = forever.

frequency number <optional>
250

Frequency is how often to emit the particles, given in ms.

quantity number <optional>
1

How many particles to launch each time the frequency is met. Can never be > Emitter.maxParticles.

total number <optional>
-1

How many particles to launch in total. If -1 it will carry on indefinitely.

immediate boolean <optional>
true

Should the flow start immediately (true) or wait until the first frequency event? (false)

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 468

forEach(callback, callbackContext, checkExists, args)

Call a function on each child in this group.

Additional arguments for the callback can be specified after the checkExists parameter. For example,

Group.forEach(awardBonusGold, this, true, 100, 500)

would invoke awardBonusGold function with the parameters (child, 100, 500).

Note: This check will skip any children which are Groups themselves.

Parameters:
Name Type Argument Default Description
callback function

The function that will be called for each applicable child. The child will be passed as the first argument.

callbackContext object

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

checkExists boolean <optional>
false

If set only children matching for which exists is true will be passed to the callback, otherwise all children will be passed.

args any <optional>
<repeatable>
(none)

Additional arguments to pass to the callback function, after the child item.

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

forEachAlive(callback, callbackContext, args)

Call a function on each alive child in this group.

See forEach for details.

Parameters:
Name Type Argument Default Description
callback function

The function that will be called for each applicable child. The child will be passed as the first argument.

callbackContext object

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

args any <optional>
<repeatable>
(none)

Additional arguments to pass to the callback function, after the child item.

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

forEachDead(callback, callbackContext, args)

Call a function on each dead child in this group.

See forEach for details.

Parameters:
Name Type Argument Default Description
callback function

The function that will be called for each applicable child. The child will be passed as the first argument.

callbackContext object

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

args any <optional>
<repeatable>
(none)

Additional arguments to pass to the callback function, after the child item.

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

forEachExists(callback, callbackContext, args)

Call a function on each existing child in this group.

See forEach for details.

Parameters:
Name Type Argument Default Description
callback function

The function that will be called for each applicable child. The child will be passed as the first argument.

callbackContext object

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

args any <optional>
<repeatable>
(none)

Additional arguments to pass to the callback function, after the child item.

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

getAll(property, value, startIndex, endIndex) → {any}

Returns all children in this Group.

You can optionally specify a matching criteria using the property and value arguments.

For example: getAll('exists', true) would return only children that have their exists property set.

Optionally you can specify a start and end index. For example if this Group had 100 children,
and you set startIndex to 0 and endIndex to 50, it would return a random child from only
the first 50 children in the Group.

Parameters:
Name Type Argument Default Description
property string <optional>

An optional property to test against the value argument.

value any <optional>

If property is set then Child.property must strictly equal this value to be included in the results.

startIndex integer <optional>
0

The first child index to start the search from.

endIndex integer <optional>

The last child index to search up until.

Returns:
any -

A random existing child of this Group.

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

getAt(index) → {DisplayObject|integer}

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

Parameters:
Name Type Description
index integer

The index to return the child from.

Returns:
DisplayObject | integer -

The child that was found at the given index, or -1 for an invalid index.

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

getBottom() → {any}

Returns the child at the bottom of this group.

The bottom child the child being displayed (rendered) below every other child.

Returns:
any -

The child at the bottom of the Group.

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

getBounds(targetCoordinateSpace) → {Rectangle}

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

Parameters:
Name Type Argument Description
targetCoordinateSpace PIXIDisplayObject | PIXIMatrix <optional>

Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.

Returns:
Rectangle -

The rectangular bounding area

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

getByName(name) → {any}

Searches the Group for the first instance of a child with the name
property matching the given argument. Should more than one child have
the same name only the first instance is returned.

Parameters:
Name Type Description
name string

The name to search for.

Returns:
any -

The first child with a matching name, or null if none were found.

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

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 153

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 112

getClosestTo(object, callback, callbackContext) → {any}

Get the closest child to given Object, with optional callback to filter children.

This can be a Sprite, Group, Image or any object with public x and y properties.

'close' is determined by the distance from the objects x and y properties compared to the childs x and y properties.

You can use the optional callback argument to apply your own filter to the distance checks.
If the child is closer then the previous child, it will be sent to callback as the first argument,
with the distance as the second. The callback should return true if it passes your
filtering criteria, otherwise it should return false.

Parameters:
Name Type Argument Description
object any

The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.

callback function <optional>

The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return true if the child passes the matching criteria.

callbackContext object <optional>

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

Returns:
any -

The child closest to given object, or null if no child was found.

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

getFirstAlive(createIfNull, x, y, key, frame) → {DisplayObject}

Get the first child that is alive (child.alive === true).

This is handy for choosing a squad leader, etc.

You can use the optional argument createIfNull to create a new Game Object if no alive ones were found in this Group.

It works by calling Group.create passing it the parameters given to this method, and returning the new child.

If a child was found , createIfNull is false and you provided the additional arguments then the child
will be reset and/or have a new texture loaded on it. This is handled by Group.resetChild.

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

If true and no alive children are found a new one is created.

x number <optional>

The x coordinate to reset the child to. The value is in relation to the group.x point.

y number <optional>

The y coordinate to reset the child to. The value is in relation to the group.y point.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

Returns:

The alive dead child, or null if none found and createIfNull was false.

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

getFirstDead(createIfNull, x, y, key, frame) → {DisplayObject}

Get the first child that is dead (child.alive === false).

This is handy for checking if everything has been wiped out and adding to the pool as needed.

You can use the optional argument createIfNull to create a new Game Object if no dead ones were found in this Group.

It works by calling Group.create passing it the parameters given to this method, and returning the new child.

If a child was found , createIfNull is false and you provided the additional arguments then the child
will be reset and/or have a new texture loaded on it. This is handled by Group.resetChild.

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

If true and no dead children are found a new one is created.

x number <optional>

The x coordinate to reset the child to. The value is in relation to the group.x point.

y number <optional>

The y coordinate to reset the child to. The value is in relation to the group.y point.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

Returns:

The first dead child, or null if none found and createIfNull was false.

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

getFirstExists(exists, createIfNull, x, y, key, frame) → {DisplayObject}

Get the first display object that exists, or doesn't exist.

You can use the optional argument createIfNull to create a new Game Object if none matching your exists argument were found in this Group.

It works by calling Group.create passing it the parameters given to this method, and returning the new child.

If a child was found , createIfNull is false and you provided the additional arguments then the child
will be reset and/or have a new texture loaded on it. This is handled by Group.resetChild.

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

If true, find the first existing child; otherwise find the first non-existing child.

createIfNull boolean <optional>
false

If true and no alive children are found a new one is created.

x number <optional>

The x coordinate to reset the child to. The value is in relation to the group.x point.

y number <optional>

The y coordinate to reset the child to. The value is in relation to the group.y point.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

Returns:

The first child, or null if none found and createIfNull was false.

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

getFurthestFrom(object, callback, callbackContext) → {any}

Get the child furthest away from the given Object, with optional callback to filter children.

This can be a Sprite, Group, Image or any object with public x and y properties.

'furthest away' is determined by the distance from the objects x and y properties compared to the childs x and y properties.

You can use the optional callback argument to apply your own filter to the distance checks.
If the child is closer then the previous child, it will be sent to callback as the first argument,
with the distance as the second. The callback should return true if it passes your
filtering criteria, otherwise it should return false.

Parameters:
Name Type Argument Description
object any

The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.

callback function <optional>

The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return true if the child passes the matching criteria.

callbackContext object <optional>

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

Returns:
any -

The child furthest from the given object, or null if no child was found.

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

getIndex(child) → {integer}

Get the index position of the given child in this group, which should match the child's z property.

Parameters:
Name Type Description
child any

The child to get the index for.

Returns:
integer -

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

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

getLocalBounds() → {Rectangle}

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

Returns:
Rectangle -

The rectangular bounding area

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

getRandom(startIndex, length) → {any}

Returns a random child from the group.

Parameters:
Name Type Argument Default Description
startIndex integer <optional>
0

Offset from the front of the group (lowest child).

length integer <optional>
(to top)

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 2362

getRandomExists(startIndex, endIndex) → {any}

Returns a random child from the Group that has exists set to true.

Optionally you can specify a start and end index. For example if this Group had 100 children,
and you set startIndex to 0 and endIndex to 50, it would return a random child from only
the first 50 children in the Group.

Parameters:
Name Type Argument Default Description
startIndex integer <optional>
0

The first child index to start the search from.

endIndex integer <optional>

The last child index to search up to.

Returns:
any -

A random child of this Group that exists.

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

getTop() → {any}

Return the child at the top of this group.

The top child is the child displayed (rendered) above every other child.

Returns:
any -

The child at the top of the Group.

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

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 any

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

key Array.<string>

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 1103

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

Iterates over the children of the group performing one of several actions for matched children.

A child is considered a match when it has a property, named key, whose value is equal to value
according to a strict equality comparison.

The result depends on the returnType:

  • RETURN_TOTAL:
    The callback, if any, is applied to all matching children. The number of matched children is returned.
  • RETURN_NONE:
    The callback, if any, is applied to all matching children. No value is returned.
  • RETURN_CHILD:
    The callback, if any, is applied to the first matching child and the first matched child is returned.
    If there is no matching child then null is returned.

If args is specified it must be an array. The matched child will be assigned to the first
element and the entire array will be applied to the callback function.

Parameters:
Name Type Argument Default Description
key string

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

value any

A child matches if child[key] === value is true.

returnType integer

How to iterate the children and what to return.

callback function <optional>
null

Optional function that will be called on each matching child. The matched child is supplied as the first argument.

callbackContext object <optional>

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

args Array.<any> <optional>
(none)

The arguments supplied to to the callback; the first array index (argument) will be replaced with the matched child.

Returns:
any -

Returns either an integer (for RETURN_TOTAL), the first matched child (for RETURN_CHILD), or null.

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

kill() → {Phaser.Particles.Arcade.Emitter}

Call this function to turn off all the particles and the emitter.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 415

makeParticles(keys, frames, quantity, collide, collideWorldBounds, particleArguments) → {Phaser.Particles.Arcade.Emitter}

This function generates a new set of particles for use by this emitter.
The particles are stored internally waiting to be emitted via Emitter.start.

Parameters:
Name Type Argument Default Description
keys array | string

A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.

frames array | number <optional>
0

A frame number, or array of frames that the sprite will use. If an array one is picked at random.

quantity number <optional>

The number of particles to generate. If not given it will use the value of Emitter.maxParticles. If the value is greater than Emitter.maxParticles it will use Emitter.maxParticles as the quantity.

collide boolean <optional>
false

If you want the particles to be able to collide with other Arcade Physics bodies then set this to true.

collideWorldBounds boolean <optional>
false

A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.

particleArguments object <optional>
null

Custom arguments to pass to your particle class

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 341

moveAll(group, silent) → {Phaser.Group}

Moves all children from this Group to the Group given.

Parameters:
Name Type Argument Default Description
group Phaser.Group

The new Group to which the children will be moved to.

silent boolean <optional>
false

If true the children will not dispatch the onAddedToGroup event for the new Group.

Returns:

The Group to which all the children were moved.

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

moveDown(child) → {any}

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

Parameters:
Name Type Description
child any

The child to move down in the group.

Returns:
any -

The child that was moved.

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

moveUp(child) → {any}

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

Parameters:
Name Type Description
child any

The child to move up in the group.

Returns:
any -

The child that was moved.

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

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 for each child.

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 1419

next() → {any}

Advances the group cursor to the next (higher) object in the group.

If the cursor is at the end of the group (top child) it is moved the start of the group (bottom child).

Returns:
any -

The child the cursor now points to.

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

<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 1668

<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 1610

previous() → {any}

Moves the group cursor to the previous (lower) child in the group.

If the cursor is at the start of the group (bottom child) it is moved to the end (top child).

Returns:
any -

The child the cursor now points to.

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

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), and optionally destroy the child.

If the group cursor was referring to the removed child it is updated to refer to the next child.

Parameters:
Name Type Argument Default Description
child any

The child to remove.

destroy boolean <optional>
false

If true destroy will be invoked on the removed child.

silent boolean <optional>
false

If true the 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 2443

removeAll(destroy, silent, destroyTexture)

Removes all children from this Group, but does not remove the group from its parent.

The children can be optionally destroyed as they are removed.

You can also optionally also destroy the BaseTexture the Child is using. Be careful if you've
more than one Game Object sharing the same BaseTexture.

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

If true destroy will be invoked on each removed child.

silent boolean <optional>
false

If true the children will not dispatch their onRemovedFromGroup events.

destroyTexture boolean <optional>
false

If true, and if the destroy argument is also true, the BaseTexture belonging to the Child is also destroyed. Note that if another Game Object is sharing the same BaseTexture it will invalidate it.

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

removeBetween(startIndex, endIndex, destroy, silent)

Removes all children from this group whose index falls beteen the given startIndex and endIndex values.

Parameters:
Name Type Argument Default Description
startIndex integer

The index to start removing children from.

endIndex integer <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

If true destroy will be invoked on each removed child.

silent boolean <optional>
false

If true the children will not dispatch their onRemovedFromGroup events.

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

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 171

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 191

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 213

removeFromHash(child) → {boolean}

Removes a child of this Group from the hash array.
This call will return false if the child is not in the hash.

Parameters:
Name Type Description
child DisplayObject

The display object to remove from this Groups hash. Must be a member of this Group and in the hash.

Returns:
boolean -

True if the child was successfully removed from the hash, otherwise false.

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

replace(oldChild, newChild) → {any}

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

If Group.enableBody is set, then a physics body will be created on the object, so long as one does not already exist.

If Group.inputEnableChildren is set, then an Input Handler will be created on the object, so long as one does not already exist.

Parameters:
Name Type Description
oldChild any

The child in this group that will be replaced.

newChild any

The child to be inserted into this group.

Returns:
any -

Returns the oldChild that was replaced within this group.

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

resetChild(child, x, y, key, frame) → {DisplayObject}

Takes a child and if the x and y arguments are given it calls child.reset(x, y) on it.

If the key and optionally the frame arguments are given, it calls child.loadTexture(key, frame) on it.

The two operations are separate. For example if you just wish to load a new texture then pass null as the x and y values.

Parameters:
Name Type Argument Description
child DisplayObject

The child to reset and/or load the texture on.

x number <optional>

The x coordinate to reset the child to. The value is in relation to the group.x point.

y number <optional>

The y coordinate to reset the child to. The value is in relation to the group.y point.

key string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture <optional>

This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache Image entry, or an instance of a RenderTexture, BitmapData, Video or PIXI.Texture.

frame string | number <optional>

If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

Returns:

The child that was reset: usually a Phaser.Sprite.

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

resetCursor(index) → {any}

Sets the group cursor to the first child 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 integer <optional>
0

Set the cursor to point to a specific index.

Returns:
any -

The child the cursor now points to.

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

reverse()

Reverses all children in this group.

This operation applies only to immediate children and does not propagate to subgroups.

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

revive() → {Phaser.Particles.Arcade.Emitter}

Handy for bringing game objects "back to life". Just sets alive and exists back to true.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 431

sendToBack(child) → {any}

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

Parameters:
Name Type Description
child any

The child to send to the bottom of this group.

Returns:
any -

The child that was moved.

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

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

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 any

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 integer <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 1245

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

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 any

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 integer <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 1276

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

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 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 any

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 integer <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 1311

setAlpha(min, max, rate, ease, yoyo) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the alpha constraints of the particles.
The rate parameter, if set to a value above zero, lets you set the speed at which the Particle change in alpha from min to max.
If rate is zero, which is the default, the particle won't change alpha - instead it will pick a random alpha between min and max on emit.

Parameters:
Name Type Argument Default Description
min number <optional>
1

The minimum value for this range.

max number <optional>
1

The maximum value for this range.

rate number <optional>
0

The rate (in ms) at which the particles will change in alpha from min to max, or set to zero to pick a random alpha between the two.

ease function <optional>
Phaser.Easing.Linear.None

If you've set a rate > 0 this is the easing formula applied between the min and max values.

yoyo boolean <optional>
false

If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values)

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 795

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 132

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.

The operations are:

  • 0: set the existing value to the given value; if force is true a new property will be created if needed
  • 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 any

The child to set the property value on.

key array

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

value any

The value that will be set.

operation integer <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 1138

setRotation(min, max) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the angular velocity constraints of the particles.

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

The minimum value for this range.

max number <optional>
0

The maximum value for this range.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 775

setScale(minX, maxX, minY, maxY, rate, ease, yoyo) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the scale constraints of the particles.
The rate parameter, if set to a value above zero, lets you set the speed and ease which the Particle uses to change in scale from min to max across both axis.
If rate is zero, which is the default, the particle won't change scale during update, instead it will pick a random scale between min and max on emit.

Parameters:
Name Type Argument Default Description
minX number <optional>
1

The minimum value of Particle.scale.x.

maxX number <optional>
1

The maximum value of Particle.scale.x.

minY number <optional>
1

The minimum value of Particle.scale.y.

maxY number <optional>
1

The maximum value of Particle.scale.y.

rate number <optional>
0

The rate (in ms) at which the particles will change in scale from min to max, or set to zero to pick a random size between the two.

ease function <optional>
Phaser.Easing.Linear.None

If you've set a rate > 0 this is the easing formula applied between the min and max values.

yoyo boolean <optional>
false

If you've set a rate > 0 you can set if the ease will yoyo or not (i.e. ease back to its original values)

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 837

setSize(width, height) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the width and height of the emitter.

Parameters:
Name Type Description
width number

The desired width of the emitter (particles are spawned randomly within these dimensions).

height number

The desired height of the emitter.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 720

setXSpeed(min, max) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the X velocity range of the emitter.

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

The minimum value for this range.

max number <optional>
0

The maximum value for this range.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 737

setYSpeed(min, max) → {Phaser.Particles.Arcade.Emitter}

A more compact way of setting the Y velocity range of the emitter.

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

The minimum value for this range.

max number <optional>
0

The maximum value for this range.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 756

sort(key, order)

Sort the children in the group according to a particular key and ordering.

Call this function to sort the group according to a particular key 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().

Internally this uses a standard JavaScript Array sort, so everything that applies there also applies here, including
alphabetical sorting, mixing strings and numbers, and Unicode sorting. See MDN for more details.

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

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

order integer <optional>
Phaser.Group.SORT_ASCENDING

Order ascending (SORT_ASCENDING) or descending (SORT_DESCENDING).

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

start(explode, lifespan, frequency, quantity, forceQuantity) → {Phaser.Particles.Arcade.Emitter}

Start emitting particles.

explode and flow are simpler methods.

There are two patterns, based on the explode argument:

  • start(true, lifespan=0, null, quantity)
  • start(false, lifespan=0, frequency=250, quantity=0)

When explode is true or forceQuantity is true, start emits quantity particles immediately. You should pass a nonzero quantity.

When explode is false and forceQuantity is false, start emits 1 particle every interval of frequency ms. If quantity is not zero, the emitter turns itself off after quantity particles have been released. If quantity is zero, the emitter keeps emitting particles as long as they are available. To emit more than 1 particle per flow interval, use flow instead.

forceQuantity seems equivalent to explode and can probably be avoided.

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

Whether the particles should all burst out at once (true) or at the frequency given (false).

lifespan number <optional>
0

How long each particle lives once emitted in ms. 0 = forever.

frequency number <optional>
250

Frequency is how often to emit 1 particle when explode is false. Value given in ms. Ignored if explode is set to true.

quantity number <optional>
0

How many particles to launch in total (not larger than maxParticles).

forceQuantity number <optional>
false

Equivalent to explodes.

Returns:

This Emitter instance.

Source - particles/arcade/Emitter.js, line 516

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 for each child.

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 1402

swap(child1, child2)

Swaps the position of two children in this group.

Both children must be in this group, a child cannot be swapped with itself, and unparented children cannot be swapped.

Parameters:
Name Type Description
child1 any

The first child to swap.

child2 any

The second child to swap.

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

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 85

update()

Called automatically by the game loop, decides when to launch particles and when to "die".

Source - particles/arcade/Emitter.js, line 272

<internal> updateZ()

Internal method that re-applies all of the children's Z values.

This must be called whenever children ordering is altered so that their z indices are correctly updated.

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

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 integer

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 992
Phaser Copyright © 2012-2016 Photon Storm Ltd.
Documentation generated by JSDoc 3.4.3 on Thu Apr 13 2017 12:05:10 GMT-0700 (PDT) using the DocStrap template.