phaser/src/math/MinSub.js

25 lines
661 B
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2019-01-15 16:20:22 +00:00
* @copyright 2019 Photon Storm Ltd.
2018-02-12 16:01:20 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2017-10-06 03:52:41 +00:00
/**
* Subtract an `amount` from `value`, limiting the minimum result to `min`.
2017-10-06 03:52:41 +00:00
*
* @function Phaser.Math.MinSub
* @since 3.0.0
*
* @param {number} value - The value to subtract from.
* @param {number} amount - The amount to subtract.
* @param {number} min - The minimum 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 MinSub = function (value, amount, min)
{
return Math.max(value - amount, min);
};
module.exports = MinSub;