mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 09:27:37 +00:00
rename function, move it to Math class
This commit is contained in:
parent
1d009f8a68
commit
0c04102731
3 changed files with 31 additions and 19 deletions
30
src/math/LinearXY.js
Normal file
30
src/math/LinearXY.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* @author Greg McLean <GregDevProjects>
|
||||
* @copyright 2021 Photon Storm Ltd.
|
||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interpolates two given Vectors and returns a new Vector between them.
|
||||
*
|
||||
* Does not modify either of the passed Vectors.
|
||||
*
|
||||
* @function Phaser.Math.LinearXY
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} vector1 - Starting vector
|
||||
* @param {Phaser.Math.Vector2} vector2 - Ending vector
|
||||
* @param {number} [t=0] - The percentage between vector1 and vector2 to return, represented as a number between 0 and 1.
|
||||
*
|
||||
* @return {Phaser.Math.Vector2} The step t% of the way between vector1 and vector2.
|
||||
*/
|
||||
var LinearXY = function (vector1, vector2, t)
|
||||
{
|
||||
if (t === undefined)
|
||||
{
|
||||
t = 0;
|
||||
}
|
||||
return vector1.clone().lerp(vector2, t);
|
||||
};
|
||||
|
||||
module.exports = LinearXY;
|
|
@ -767,23 +767,4 @@ Vector2.DOWN = new Vector2(0, 1);
|
|||
*/
|
||||
Vector2.ONE = new Vector2(1, 1);
|
||||
|
||||
/**
|
||||
* Interpolates two given Vectors and returns a new Vector.
|
||||
*
|
||||
* Does not modify either of the passed Vectors.
|
||||
*
|
||||
* @method Phaser.Math.Vector2
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param {Phaser.Math.Vector2} vector1 - Starting vector
|
||||
* @param {Phaser.Math.Vector2} vector2 - Ending vector
|
||||
* @param {number} [t=0] - The interpolation percentage, between 0 and 1.
|
||||
* @return {Phaser.Math.Vector2} Value of the interpolation
|
||||
*/
|
||||
Vector2.Lerp = function (vector1, vector2, t)
|
||||
{
|
||||
if (t === undefined) { t = 0; }
|
||||
return vector1.clone().lerp(vector2, t);
|
||||
};
|
||||
|
||||
module.exports = Vector2;
|
||||
|
|
|
@ -43,6 +43,7 @@ var PhaserMath = {
|
|||
IsEven: require('./IsEven'),
|
||||
IsEvenStrict: require('./IsEvenStrict'),
|
||||
Linear: require('./Linear'),
|
||||
LinearXY: require('./LinearXY'),
|
||||
MaxAdd: require('./MaxAdd'),
|
||||
Median: require('./Median'),
|
||||
MinSub: require('./MinSub'),
|
||||
|
|
Loading…
Reference in a new issue