forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveTo.js
More file actions
134 lines (120 loc) · 3.03 KB
/
Copy pathMoveTo.js
File metadata and controls
134 lines (120 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../utils/Class');
var Vector2 = require('../../math/Vector2');
/**
* @classdesc
* [description]
*
* @class MoveTo
* @memberOf Phaser.Curves
* @constructor
* @since 3.0.0
*
* @param {number} [x] - [description]
* @param {number} [y] - [description]
*/
var MoveTo = new Class({
initialize:
function MoveTo (x, y)
{
// Skip length calcs in paths
/**
* [description]
*
* @name Phaser.Curves.MoveTo#active
* @type {boolean}
* @default false
* @since 3.0.0
*/
this.active = false;
/**
* [description]
*
* @name Phaser.Curves.MoveTo#p0
* @type {Phaser.Math.Vector2}
* @since 3.0.0
*/
this.p0 = new Vector2(x, y);
},
/**
* Get point at relative position in curve according to length.
*
* @method Phaser.Curves.MoveTo#getPoint
* @since 3.0.0
*
* @generic {Phaser.Math.Vector2} O - [out,$return]
*
* @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end.
* @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created.
*
* @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned.
*/
getPoint: function (t, out)
{
if (out === undefined) { out = new Vector2(); }
return out.copy(this.p0);
},
/**
* [description]
*
* @method Phaser.Curves.MoveTo#getPointAt
* @since 3.0.0
*
* @generic {Phaser.Math.Vector2} O - [out,$return]
*
* @param {number} u - [description]
* @param {Phaser.Math.Vector2} [out] - [description]
*
* @return {Phaser.Math.Vector2} [description]
*/
getPointAt: function (u, out)
{
return this.getPoint(u, out);
},
/**
* Gets the resolution of this curve.
*
* @method Phaser.Curves.MoveTo#getResolution
* @since 3.0.0
*
* @return {number} The resolution of this curve. For a MoveTo the value is always 1.
*/
getResolution: function ()
{
return 1;
},
/**
* Gets the length of this curve.
*
* @method Phaser.Curves.MoveTo#getLength
* @since 3.0.0
*
* @return {number} The length of this curve. For a MoveTo the value is always 0.
*/
getLength: function ()
{
return 0;
},
/**
* [description]
*
* @method Phaser.Curves.MoveTo#toJSON
* @since 3.0.0
*
* @return {JSONCurve} [description]
*/
toJSON: function ()
{
return {
type: 'MoveTo',
points: [
this.p0.x, this.p0.y
]
};
}
});
module.exports = MoveTo;