You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/curves/path/Path.js
+36-25Lines changed: 36 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -624,7 +624,9 @@ var Path = new Class({
624
624
},
625
625
626
626
/**
627
-
* [description]
627
+
* 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.
628
+
*
629
+
* When calling this method multiple times, the points are not guaranteed to be equally spaced spatially.
628
630
*
629
631
* @method Phaser.Curves.Path#getRandomPoint
630
632
* @since 3.0.0
@@ -633,7 +635,7 @@ var Path = new Class({
633
635
*
634
636
* @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created.
635
637
*
636
-
* @return {Phaser.Math.Vector2} [description]
638
+
* @return {Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided.
637
639
*/
638
640
getRandomPoint: function(out)
639
641
{
@@ -643,14 +645,16 @@ var Path = new Class({
643
645
},
644
646
645
647
/**
646
-
* Creates a straight Line Curve from the ending point of the Path to the given coordinates.
648
+
* Divides this Path into a set of equally spaced points,
649
+
*
650
+
* The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially.
647
651
*
648
652
* @method Phaser.Curves.Path#getSpacedPoints
649
653
* @since 3.0.0
650
654
*
651
-
* @param {integer} [divisions=40] - The X coordinate of the line's ending point, or the line's ending point as a `Vector2`.
655
+
* @param {integer} [divisions=40] - The amount of points to divide this Path into.
652
656
*
653
-
* @return {Phaser.Math.Vector2[]} [description]
657
+
* @return {Phaser.Math.Vector2[]} A list of the points this path was subdivided into.
654
658
*/
655
659
getSpacedPoints: function(divisions)
656
660
{
@@ -672,16 +676,16 @@ var Path = new Class({
672
676
},
673
677
674
678
/**
675
-
* [description]
679
+
* Returns the starting point of the Path.
676
680
*
677
681
* @method Phaser.Curves.Path#getStartPoint
678
682
* @since 3.0.0
679
683
*
680
684
* @generic {Phaser.Math.Vector2} O - [out,$return]
* @param {Phaser.Math.Vector2[]} points - The points the newly created spline curve should consist of.
729
731
*
730
-
* @return {Phaser.Curves.Path} [description]
732
+
* @return {Phaser.Curves.Path} This Path object.
731
733
*/
732
734
splineTo: function(points)
733
735
{
@@ -737,28 +739,37 @@ var Path = new Class({
737
739
},
738
740
739
741
/**
740
-
* [description]
742
+
* Creates a "gap" in this path from the path's current end point to the given coordinates.
743
+
*
744
+
* After calling this function, this Path's end point will be equal to the given coordinates
741
745
*
742
746
* @method Phaser.Curves.Path#moveTo
743
747
* @since 3.0.0
744
748
*
745
-
* @param {number} x - [description]
746
-
* @param {number} y - [description]
749
+
* @param {(number|Phaser.Math.Vector2)} x - The X coordinate of the position to move the path's end point to, or a `Vector2` containing the entire new end point.
750
+
* @param {number} y - The Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate.
747
751
*
748
-
* @return {Phaser.Curves.Path} [description]
752
+
* @return {Phaser.Curves.Path} This Path object.
749
753
*/
750
754
moveTo: function(x,y)
751
755
{
752
-
returnthis.add(newMovePathTo(x,y));
756
+
if(xinstanceofVector2)
757
+
{
758
+
returnthis.add(newMovePathTo(x.x,x.y));
759
+
}
760
+
else
761
+
{
762
+
returnthis.add(newMovePathTo(x,y));
763
+
}
753
764
},
754
765
755
766
/**
756
-
* [description]
767
+
* Converts this Path to a JSON object containing the path information and its consitutent curves.
0 commit comments