2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-01 16:51:51 +00:00
|
|
|
var GetValue = require('../../utils/object/GetValue');
|
|
|
|
|
2018-02-10 17:11:36 +00:00
|
|
|
/**
|
2018-10-22 11:12:31 +00:00
|
|
|
* Extracts an array of targets from a Tween configuration object.
|
|
|
|
*
|
|
|
|
* The targets will be looked for in a `targets` property. If it's a function, its return value will be used as the result.
|
2018-02-10 17:11:36 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Tweens.Builders.GetTargets
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-10-22 11:12:31 +00:00
|
|
|
* @param {object} config - The configuration object to use.
|
2018-02-10 17:11:36 +00:00
|
|
|
*
|
2018-10-22 11:12:31 +00:00
|
|
|
* @return {array} An array of targets (may contain only one element), or `null` if no targets were specified.
|
2018-02-10 17:11:36 +00:00
|
|
|
*/
|
2017-09-01 16:51:51 +00:00
|
|
|
var GetTargets = function (config)
|
|
|
|
{
|
|
|
|
var targets = GetValue(config, 'targets', null);
|
|
|
|
|
|
|
|
if (targets === null)
|
|
|
|
{
|
|
|
|
return targets;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof targets === 'function')
|
|
|
|
{
|
|
|
|
targets = targets.call();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Array.isArray(targets))
|
|
|
|
{
|
|
|
|
targets = [ targets ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return targets;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetTargets;
|