mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Group.getByName 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.
This commit is contained in:
parent
65f8f111c8
commit
ecbff44354
2 changed files with 24 additions and 0 deletions
|
@ -325,6 +325,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
* Polygon now takes an array of arrays as a new type when constructing it: `[[x1, y1], [x2, y2]]` (thanks @ShimShamSam #2360)
|
||||
* Text has a new property `maxLines` which is the maximum number of lines to be shown for wrapped text. If set to 0 (the default) there is limit. This prevents wrapped text from overflowing on a fixed layout (thanks @slashman #2410)
|
||||
* `outOfCameraBoundsKill` is a new boolean property that all Game Objects with the `InWorld` component has. If `autoCull` and this property are both `true` then the Object will be automatically killed if it leaves the camera bounds (thanks @jakewilson #2402)
|
||||
* Group.getByName 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.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -799,6 +799,29 @@ Phaser.Group.prototype.getIndex = function (child) {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @method Phaser.Group#getByName
|
||||
* @param {string} name - The name to search for.
|
||||
* @return {any} The first child with a matching name, or null if none were found.
|
||||
*/
|
||||
Phaser.Group.prototype.getByName = function (name) {
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
if (this.children[i].name === name)
|
||||
{
|
||||
return this.children[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces a child of this group with the given newChild. The newChild cannot be a member of this group.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue