ArraySet.getByKey gets an item from the set based on the property strictly equaling the value given.

This commit is contained in:
photonstorm 2015-02-22 19:30:23 +00:00
parent 8d71e8a32c
commit 5fd066c610
2 changed files with 26 additions and 0 deletions

View file

@ -157,6 +157,7 @@ We've also removed functions and properties from Pixi classes that Phaser doesn'
* Tween.repeat has a new parameter `repeatDelay` which allows you to set the delay (in ms) before a tween will repeat itself.
* Tween.yoyo has a new parameter `yoyoDelay` which allows you to set the delay (in ms) before a tween will start a yoyo.
* Tween.interpolation has a new parameter `context` which allows you to define the context in which the interpolation function will run.
* ArraySet.getByKey gets an item from the set based on the property strictly equaling the value given.
### Bug Fixes

View file

@ -67,6 +67,31 @@ Phaser.ArraySet.prototype = {
},
/**
* Gets an item from the set based on the property strictly equaling the value given.
* Returns null if not found.
*
* @method Phaser.ArraySet#getByKey
* @param {string} property - The property to check against the value.
* @param {any} value - The value to check if the property strictly equals.
* @return {any} The item that was found, or null if nothing matched.
*/
getByKey: function (property, value) {
var i = this.list.length;
while (i--)
{
if (this.list[i][property] === value)
{
return this.list[i];
}
}
return null;
},
/**
* Checks for the item within this list.
*