World#getFirstDead()

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 code: core/Group.js (Line 2135)
doc_phaser
2017-02-14 11:21:03
Comments
Leave a Comment

Please login to continue.