Skip to content

Commit e5af0a0

Browse files
rename function, move it to Math class
1 parent 1d009f8 commit e5af0a0

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

src/math/LinearXY.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @author Greg McLean <GregDevProjects>
3+
* @copyright 2021 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* Interpolates two given Vectors and returns a new Vector between them.
9+
*
10+
* Does not modify either of the passed Vectors.
11+
*
12+
* @method Phaser.Math.LinearXY
13+
* @since 3.6.0
14+
*
15+
* @param {Phaser.Math.Vector2} vector1 - Starting vector
16+
* @param {Phaser.Math.Vector2} vector2 - Ending vector
17+
* @param {number} [t=0] - The percentage between vector1 and vector2 to return, represented as a number between 0 and 1.
18+
* @return {Phaser.Math.Vector2} Value of the interpolation
19+
*/
20+
var LinearXY = function (vector1, vector2, t)
21+
{
22+
if (t === undefined)
23+
{
24+
t = 0;
25+
}
26+
return vector1.clone().lerp(vector2, t);
27+
};
28+
29+
module.exports = LinearXY;

src/math/Vector2.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -767,23 +767,4 @@ Vector2.DOWN = new Vector2(0, 1);
767767
*/
768768
Vector2.ONE = new Vector2(1, 1);
769769

770-
/**
771-
* Interpolates two given Vectors and returns a new Vector.
772-
*
773-
* Does not modify either of the passed Vectors.
774-
*
775-
* @method Phaser.Math.Vector2
776-
* @since 3.6.0
777-
*
778-
* @param {Phaser.Math.Vector2} vector1 - Starting vector
779-
* @param {Phaser.Math.Vector2} vector2 - Ending vector
780-
* @param {number} [t=0] - The interpolation percentage, between 0 and 1.
781-
* @return {Phaser.Math.Vector2} Value of the interpolation
782-
*/
783-
Vector2.Lerp = function (vector1, vector2, t)
784-
{
785-
if (t === undefined) { t = 0; }
786-
return vector1.clone().lerp(vector2, t);
787-
};
788-
789770
module.exports = Vector2;

src/math/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var PhaserMath = {
4343
IsEven: require('./IsEven'),
4444
IsEvenStrict: require('./IsEvenStrict'),
4545
Linear: require('./Linear'),
46+
LinearXY: require('./LinearXY'),
4647
MaxAdd: require('./MaxAdd'),
4748
Median: require('./Median'),
4849
MinSub: require('./MinSub'),

0 commit comments

Comments
 (0)