Particles.Arcade.Emitter#getFirstAlive()

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 code: core/Group.js (Line 2105)
doc_phaser
2017-02-14 10:57:31
Comments
Leave a Comment

Please login to continue.