phaser/src/math/MaxAdd.js

25 lines
623 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2023-01-02 17:36:27 +00:00
* @copyright 2013-2023 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-10-06 03:52:41 +00:00
/**
* Add an `amount` to a `value`, limiting the maximum result to `max`.
2017-10-06 03:52:41 +00:00
*
* @function Phaser.Math.MaxAdd
* @since 3.0.0
*
* @param {number} value - The value to add to.
* @param {number} amount - The amount to add.
* @param {number} max - The maximum value to return.
2017-10-06 03:52:41 +00:00
*
* @return {number} The resulting value.
2017-10-06 03:52:41 +00:00
*/
var MaxAdd = function (value, amount, max)
{
return Math.min(value + amount, max);
};
module.exports = MaxAdd;