Skip to content

Commit 2d0edf2

Browse files
authored
Merge branch 'master' into master
2 parents 9bb02d5 + eab83de commit 2d0edf2

6 files changed

Lines changed: 97 additions & 61 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157

158158
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
159159

160-
@fselcukcan Bambosh @louisth @hexus @javigaralva @samme @BeLi4L @jcyuan
160+
@fselcukcan Bambosh @louisth @hexus @javigaralva @samme @BeLi4L @jcyuan @javigaralva
161161

162162

163163
## Version 3.21.0 - Senku - 22nd November 2019

src/curves/Curve.js

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var Vector2 = require('../math/Vector2');
2020
* @constructor
2121
* @since 3.0.0
2222
*
23-
* @param {string} type - [description]
23+
* @param {string} type - The curve type.
2424
*/
2525
var Curve = new Class({
2626

@@ -78,7 +78,7 @@ var Curve = new Class({
7878
this.needsUpdate = true;
7979

8080
/**
81-
* [description]
81+
* For a curve on a Path, `false` means the Path will ignore this curve.
8282
*
8383
* @name Phaser.Curves.Curve#active
8484
* @type {boolean}
@@ -131,7 +131,7 @@ var Curve = new Class({
131131
// So you can chain graphics calls
132132
return graphics.strokePoints(this.getPoints(pointsTotal));
133133
},
134-
134+
135135
/**
136136
* Returns a Rectangle where the position and dimensions match the bounds of this Curve.
137137
*
@@ -187,7 +187,7 @@ var Curve = new Class({
187187
},
188188

189189
/**
190-
* [description]
190+
* Get a point at the end of the curve.
191191
*
192192
* @method Phaser.Curves.Curve#getEndPoint
193193
* @since 3.0.0
@@ -209,7 +209,7 @@ var Curve = new Class({
209209
* @method Phaser.Curves.Curve#getLength
210210
* @since 3.0.0
211211
*
212-
* @return {number} [description]
212+
* @return {number} The total length of the curve.
213213
*/
214214
getLength: function ()
215215
{
@@ -220,14 +220,22 @@ var Curve = new Class({
220220

221221

222222
/**
223-
* Get list of cumulative segment lengths
223+
* Get a list of cumulative segment lengths.
224+
*
225+
* These lengths are
226+
*
227+
* - [0] 0
228+
* - [1] The first segment
229+
* - [2] The first and second segment
230+
* - ...
231+
* - [divisions] All segments
224232
*
225233
* @method Phaser.Curves.Curve#getLengths
226234
* @since 3.0.0
227235
*
228-
* @param {integer} [divisions] - [description]
236+
* @param {integer} [divisions] - The number of divisions or segments.
229237
*
230-
* @return {number[]} [description]
238+
* @return {number[]} An array of cumulative lengths.
231239
*/
232240
getLengths: function (divisions)
233241
{
@@ -268,17 +276,17 @@ var Curve = new Class({
268276
// - u [0 .. 1]
269277

270278
/**
271-
* [description]
279+
* Get a point at a relative position on the curve, by arc length.
272280
*
273281
* @method Phaser.Curves.Curve#getPointAt
274282
* @since 3.0.0
275283
*
276284
* @generic {Phaser.Math.Vector2} O - [out,$return]
277285
*
278-
* @param {number} u - [description]
279-
* @param {Phaser.Math.Vector2} [out] - [description]
286+
* @param {number} u - The relative position, [0..1].
287+
* @param {Phaser.Math.Vector2} [out] - A point to store the result in.
280288
*
281-
* @return {Phaser.Math.Vector2} [description]
289+
* @return {Phaser.Math.Vector2} The point.
282290
*/
283291
getPointAt: function (u, out)
284292
{
@@ -290,15 +298,25 @@ var Curve = new Class({
290298
// Get sequence of points using getPoint( t )
291299

292300
/**
293-
* [description]
301+
* Get a sequence of evenly spaced points from the curve.
302+
*
303+
* You can pass `divisions`, `stepRate`, or neither.
304+
*
305+
* The number of divisions will be
306+
*
307+
* 1. `divisions`, if `divisions` > 0; or
308+
* 2. `this.getLength / stepRate`, if `stepRate` > 0; or
309+
* 3. `this.defaultDivisions`
310+
*
311+
* `1 + divisions` points will be returned.
294312
*
295313
* @method Phaser.Curves.Curve#getPoints
296314
* @since 3.0.0
297315
*
298316
* @generic {Phaser.Math.Vector2[]} O - [out,$return]
299317
*
300-
* @param {integer} divisions - The number of evenly spaced points from the curve to return. If falsy, step param will be used to calculate the number of points.
301-
* @param {number} step - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
318+
* @param {integer} [divisions] - The number of divisions to make.
319+
* @param {number} [stepRate] - The curve distance between points, implying `divisions`.
302320
* @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in.
303321
*
304322
* @return {(array|Phaser.Math.Vector2[])} An array of Points from the curve.
@@ -329,16 +347,16 @@ var Curve = new Class({
329347
},
330348

331349
/**
332-
* [description]
350+
* Get a random point from the curve.
333351
*
334352
* @method Phaser.Curves.Curve#getRandomPoint
335353
* @since 3.0.0
336354
*
337355
* @generic {Phaser.Math.Vector2} O - [out,$return]
338356
*
339-
* @param {Phaser.Math.Vector2} [out] - [description]
357+
* @param {Phaser.Math.Vector2} [out] - A point object to store the result in.
340358
*
341-
* @return {Phaser.Math.Vector2} [description]
359+
* @return {Phaser.Math.Vector2} The point.
342360
*/
343361
getRandomPoint: function (out)
344362
{
@@ -350,16 +368,18 @@ var Curve = new Class({
350368
// Get sequence of points using getPointAt( u )
351369

352370
/**
353-
* [description]
371+
* Get a sequence of equally spaced points (by arc distance) from the curve.
372+
*
373+
* `1 + divisions` points will be returned.
354374
*
355375
* @method Phaser.Curves.Curve#getSpacedPoints
356376
* @since 3.0.0
357377
*
358-
* @param {integer} [divisions] - The number of evenly spaced points from the curve to return. If falsy, step param will be used to calculate the number of points.
359-
* @param {number} [step] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
378+
* @param {integer} [divisions=this.defaultDivisions] - The number of divisions to make.
379+
* @param {number} [stepRate] - Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
360380
* @param {(array|Phaser.Math.Vector2[])} [out] - An optional array to store the points in.
361381
*
362-
* @return {Phaser.Math.Vector2[]} [description]
382+
* @return {Phaser.Math.Vector2[]} An array of points.
363383
*/
364384
getSpacedPoints: function (divisions, stepRate, out)
365385
{
@@ -389,16 +409,16 @@ var Curve = new Class({
389409
},
390410

391411
/**
392-
* [description]
412+
* Get a point at the start of the curve.
393413
*
394414
* @method Phaser.Curves.Curve#getStartPoint
395415
* @since 3.0.0
396416
*
397417
* @generic {Phaser.Math.Vector2} O - [out,$return]
398418
*
399-
* @param {Phaser.Math.Vector2} [out] - [description]
419+
* @param {Phaser.Math.Vector2} [out] - A point to store the result in.
400420
*
401-
* @return {Phaser.Math.Vector2} [description]
421+
* @return {Phaser.Math.Vector2} The point.
402422
*/
403423
getStartPoint: function (out)
404424
{
@@ -408,7 +428,7 @@ var Curve = new Class({
408428
},
409429

410430
/**
411-
* Returns a unit vector tangent at t
431+
* Get a unit vector tangent at a relative position on the curve.
412432
* In case any sub curve does not implement its tangent derivation,
413433
* 2 points a small delta apart will be used to find its gradient
414434
* which seems to give a reasonable approximation
@@ -418,8 +438,8 @@ var Curve = new Class({
418438
*
419439
* @generic {Phaser.Math.Vector2} O - [out,$return]
420440
*
421-
* @param {number} t - [description]
422-
* @param {Phaser.Math.Vector2} [out] - [description]
441+
* @param {number} t - The relative position on the curve, [0..1].
442+
* @param {Phaser.Math.Vector2} [out] - A vector to store the result in.
423443
*
424444
* @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001)
425445
*/
@@ -450,17 +470,17 @@ var Curve = new Class({
450470
},
451471

452472
/**
453-
* [description]
473+
* Get a unit vector tangent at a relative position on the curve, by arc length.
454474
*
455475
* @method Phaser.Curves.Curve#getTangentAt
456476
* @since 3.0.0
457477
*
458478
* @generic {Phaser.Math.Vector2} O - [out,$return]
459479
*
460-
* @param {number} u - [description]
461-
* @param {Phaser.Math.Vector2} [out] - [description]
480+
* @param {number} u - The relative position on the curve, [0..1].
481+
* @param {Phaser.Math.Vector2} [out] - A vector to store the result in.
462482
*
463-
* @return {Phaser.Math.Vector2} [description]
483+
* @return {Phaser.Math.Vector2} The tangent vector.
464484
*/
465485
getTangentAt: function (u, out)
466486
{
@@ -575,10 +595,12 @@ var Curve = new Class({
575595
},
576596

577597
/**
578-
* [description]
598+
* Calculate and cache the arc lengths.
579599
*
580600
* @method Phaser.Curves.Curve#updateArcLengths
581601
* @since 3.0.0
602+
*
603+
* @see Phaser.Curves.Curve#getLengths()
582604
*/
583605
updateArcLengths: function ()
584606
{

src/curves/SplineCurve.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ var Vector2 = require('../math/Vector2');
1313

1414
/**
1515
* @classdesc
16-
* [description]
16+
* Create a smooth 2d spline curve from a series of points.
1717
*
1818
* @class Spline
1919
* @extends Phaser.Curves.Curve
2020
* @memberof Phaser.Curves
2121
* @constructor
2222
* @since 3.0.0
2323
*
24-
* @param {Phaser.Math.Vector2[]} [points] - [description]
24+
* @param {(Phaser.Math.Vector2[]|number[]|number[][])} [points] - The points that configure the curve.
2525
*/
2626
var SplineCurve = new Class({
2727

@@ -36,7 +36,7 @@ var SplineCurve = new Class({
3636
Curve.call(this, 'SplineCurve');
3737

3838
/**
39-
* [description]
39+
* The Vector2 points that configure the curve.
4040
*
4141
* @name Phaser.Curves.Spline#points
4242
* @type {Phaser.Math.Vector2[]}
@@ -49,12 +49,12 @@ var SplineCurve = new Class({
4949
},
5050

5151
/**
52-
* [description]
52+
* Add a list of points to the current list of Vector2 points of the curve.
5353
*
5454
* @method Phaser.Curves.Spline#addPoints
5555
* @since 3.0.0
5656
*
57-
* @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description]
57+
* @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - The points that configure the curve.
5858
*
5959
* @return {Phaser.Curves.Spline} This curve object.
6060
*/
@@ -89,15 +89,15 @@ var SplineCurve = new Class({
8989
},
9090

9191
/**
92-
* [description]
92+
* Add a point to the current list of Vector2 points of the curve.
9393
*
9494
* @method Phaser.Curves.Spline#addPoint
9595
* @since 3.0.0
9696
*
97-
* @param {number} x - [description]
98-
* @param {number} y - [description]
97+
* @param {number} x - The x coordinate of this curve
98+
* @param {number} y - The y coordinate of this curve
9999
*
100-
* @return {Phaser.Math.Vector2} [description]
100+
* @return {Phaser.Math.Vector2} The new Vector2 added to the curve
101101
*/
102102
addPoint: function (x, y)
103103
{
@@ -176,7 +176,7 @@ var SplineCurve = new Class({
176176
},
177177

178178
/**
179-
* [description]
179+
* Exports a JSON object containing this curve data.
180180
*
181181
* @method Phaser.Curves.Spline#toJSON
182182
* @since 3.0.0
@@ -202,14 +202,14 @@ var SplineCurve = new Class({
202202
});
203203

204204
/**
205-
* [description]
205+
* Imports a JSON object containing this curve data.
206206
*
207207
* @function Phaser.Curves.Spline.fromJSON
208208
* @since 3.0.0
209209
*
210210
* @param {Phaser.Types.Curves.JSONCurve} data - The JSON object containing this curve data.
211211
*
212-
* @return {Phaser.Curves.Spline} [description]
212+
* @return {Phaser.Curves.Spline} The spline curve created.
213213
*/
214214
SplineCurve.fromJSON = function (data)
215215
{

src/curves/path/Path.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,12 @@ var Path = new Class({
569569
},
570570

571571
/**
572-
* Returns the defined starting point of the Path.
573-
*
574-
* This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}.
572+
* Get a sequence of points on the path.
575573
*
576574
* @method Phaser.Curves.Path#getPoints
577575
* @since 3.0.0
578576
*
579-
* @param {integer} [divisions=12] - The number of points to divide the path in to.
577+
* @param {integer} [divisions=12] - The number of divisions per resolution per curve.
580578
*
581579
* @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path.
582580
*/
@@ -626,7 +624,7 @@ var Path = new Class({
626624

627625
/**
628626
* Returns a randomly chosen point anywhere on the path. This follows the same rules as `getPoint` in that it may return a point on any Curve inside this path.
629-
*
627+
*
630628
* When calling this method multiple times, the points are not guaranteed to be equally spaced spatially.
631629
*
632630
* @method Phaser.Curves.Path#getRandomPoint
@@ -647,7 +645,7 @@ var Path = new Class({
647645

648646
/**
649647
* Divides this Path into a set of equally spaced points,
650-
*
648+
*
651649
* The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially.
652650
*
653651
* @method Phaser.Curves.Path#getSpacedPoints
@@ -741,7 +739,7 @@ var Path = new Class({
741739

742740
/**
743741
* Creates a "gap" in this path from the path's current end point to the given coordinates.
744-
*
742+
*
745743
* After calling this function, this Path's end point will be equal to the given coordinates
746744
*
747745
* @method Phaser.Curves.Path#moveTo

0 commit comments

Comments
 (0)