mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 04:23:30 +00:00
33 lines
525 B
JavaScript
33 lines
525 B
JavaScript
|
// compare = Object:
|
||
|
// {
|
||
|
// scaleX: 0.5,
|
||
|
// scaleY: 1
|
||
|
// }
|
||
|
|
||
|
var GetFirst = function (items, compare, index)
|
||
|
{
|
||
|
for (var i = index; i < items.length; i++)
|
||
|
{
|
||
|
var item = items[i];
|
||
|
|
||
|
var match = true;
|
||
|
|
||
|
for (var property in compare)
|
||
|
{
|
||
|
if (item[property] !== compare[property])
|
||
|
{
|
||
|
match = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (match)
|
||
|
{
|
||
|
return item;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
};
|
||
|
|
||
|
module.exports = GetFirst;
|