Optionalx: numberThe X coordinate of the Path's starting point or a Phaser.Types.Curves.JSONPath. Default 0.
Optionaly: numberThe Y coordinate of the Path's starting point. Default 0.
Automatically closes the path.
The cached length of each Curve in the Path.
Used internally by #getCurveLengths.
The list of Curves which make up this Path.
The default number of divisions within a curve.
The name of this Path. Empty by default and never populated by Phaser, this is left for developers to use.
The starting point of the Path.
This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point.
Creates a circular Ellipse Curve positioned at the end of the Path.
The radius of the circle.
Optionalclockwise: booleantrue to create a clockwise circle as opposed to a counter-clockwise circle. Default false.
Optionalrotation: numberThe rotation of the circle in degrees. Default 0.
Ensures that the Path is closed.
A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined startPoint, which could differ.
Calling this method on an empty Path will result in an error.
Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points.
The x coordinate of the end point. Or, if a Vector2, the p1 value.
The y coordinate of the end point. Or, if a Vector2, the p2 value.
The x coordinate of the first control point. Or, if a Vector2, the p3 value.
Optionalcontrol1Y: numberThe y coordinate of the first control point. Not used if Vector2s are provided as the first 3 arguments.
Optionalcontrol2X: numberThe x coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments.
Optionalcontrol2Y: numberThe y coordinate of the second control point. Not used if Vector2s are provided as the first 3 arguments.
Disposes of this Path, clearing its internal references to objects so they can be garbage-collected.
Draws all Curves in the Path to a Graphics Game Object.
The Graphics Game Object to draw to.
OptionalpointsTotal: numberThe number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. Default 32.
Creates an ellipse curve positioned at the previous end point, using the given parameters.
OptionalxRadius: numberThe horizontal radius of ellipse. Default 0.
OptionalyRadius: numberThe vertical radius of ellipse. Default 0.
OptionalstartAngle: numberThe start angle of the ellipse, in degrees. Default 0.
OptionalendAngle: numberThe end angle of the ellipse, in degrees. Default 360.
Optionalclockwise: booleanWhether the ellipse angles are given as clockwise (true) or counter-clockwise (false). Default false.
Optionalrotation: numberThe rotation of the ellipse, in degrees. Default 0.
Creates a Path from a Path Configuration object.
The provided object should be a Phaser.Types.Curves.JSONPath, as returned by #toJSON. Providing a malformed object may cause errors.
The JSON object containing the Path data.
Returns a Rectangle with a position and size matching the bounds of this Path.
Optionalout: OThe Rectangle to store the bounds in.
Optionalaccuracy: numberThe accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. Default 16.
Returns an array containing the length of the Path at the end of each Curve.
The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the #curves array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place.
Returns the total length of the Path.
Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path.
The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths.
The location of the point to return, between 0 and 1.
Optionalout: OThe object in which to store the calculated point.
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.
When calling this method multiple times, the points are not guaranteed to be equally spaced spatially.
Optionalout: OVector2 instance that should be used for storing the result. If undefined a new Vector2 will be created.
Divides this Path into a set of equally spaced points,
The resulting points are equally spaced with respect to the points' position on the path, but not necessarily equally spaced spatially.
Optionaldivisions: numberThe amount of points to divide this Path into. Default 40.
Creates a line curve from the previous end point to x/y.
The X coordinate of the line's end point, or a Vector2 / Vector2Like containing the entire end point.
Optionaly: numberThe Y coordinate of the line's end point, if a number was passed as the X parameter.
Creates a "gap" in this path from the path's current end point to the given coordinates.
After calling this function, this Path's end point will be equal to the given coordinates
The X coordinate of the position to move the path's end point to, or a Vector2 / Vector2Like containing the entire new end point.
Optionaly: numberThe Y coordinate of the position to move the path's end point to, if a number was passed as the X coordinate.
Creates a Quadratic Bezier Curve starting at the ending point of the Path.
The X coordinate of the second control point or, if it's a Vector2, the first control point.
Optionaly: numberThe Y coordinate of the second control point or, if x is a Vector2, the second control point.
OptionalcontrolX: numberIf x is not a Vector2, the X coordinate of the first control point.
OptionalcontrolY: numberIf x is not a Vector2, the Y coordinate of the first control point.
Converts this Path to a JSON object containing the path information and its constituent curves.
cacheLengths must be recalculated.
A Path combines multiple Curves into one continuous compound curve. It does not matter how many Curves are in the Path or what type they are.
A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path.