new Line(p0 [, p1])
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
p0 |
Phaser.Math.Vector2 | Array.<number> | The first endpoint. |
|
p1 |
Phaser.Math.Vector2 |
<optional> |
The second endpoint. |
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 17)
Extends
Members
-
active :boolean
-
For a curve on a Path,
falsemeans the Path will ignore this curve.Type:
- boolean
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- true
- Source: src/curves/Curve.js (Line 80)
-
arcLengthDivisions :number
-
The quantity of arc length divisions within the curve.
Type:
- number
- Since: 3.0.0
- Overrides:
- Default Value:
-
- 1
- Source: src/curves/LineCurve.js (Line 67)
-
cacheArcLengths :Array.<number>
-
An array of cached arc length values.
Type:
- Array.<number>
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- []
- Source: src/curves/Curve.js (Line 60)
-
defaultDivisions :number
-
The default number of divisions within the curve.
Type:
- number
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- 5
- Source: src/curves/Curve.js (Line 40)
-
needsUpdate :boolean
-
Does the data of this curve need updating?
Type:
- boolean
- Since: 3.0.0
- Inherited From:
- Default Value:
-
- true
- Source: src/curves/Curve.js (Line 70)
-
p0 :Phaser.Math.Vector2
-
The first endpoint.
Type:
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 47)
-
p1 :Phaser.Math.Vector2
-
The second endpoint.
Type:
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 56)
-
type :string
-
String based identifier for the type of curve.
Type:
- string
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 31)
Methods
-
<static> fromJSON(data)
-
Configures this line from a JSON representation.
Parameters:
Name Type Description dataPhaser.Types.Curves.JSONCurve The JSON object containing this curve data.
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 277)
Returns:
A new LineCurve object.
- Type
- Phaser.Curves.Line
-
draw(graphics)
-
Draws this curve on the given Graphics object.
The curve is drawn using
Graphics.lineBetweenso will be drawn at whatever the present Graphics line color is. The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.Parameters:
Name Type Description graphicsPhaser.GameObjects.Graphics The Graphics instance onto which this curve will be drawn.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 233)
Returns:
The Graphics object to which the curve was drawn.
-
getBounds( [out])
-
Returns a Rectangle where the position and dimensions match the bounds of this Curve.
Parameters:
Name Type Argument Description outPhaser.Geom.Rectangle <optional>
A Rectangle object to store the bounds in. If not given a new Rectangle will be created.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 78)
Returns:
A Rectangle object holding the bounds of this curve. If
outwas given it will be this object. -
getDistancePoints(distance)
-
Returns an array of points, spaced out X distance pixels apart. The smaller the distance, the larger the array will be.
Parameters:
Name Type Description distancenumber The distance, in pixels, between each point along the curve.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 169)
Returns:
An Array of Point objects.
- Type
- Array.<Phaser.Geom.Point>
-
getEndPoint( [out])
-
Get a point at the end of the curve.
Parameters:
Name Type Argument Description outPhaser.Math.Vector2 <optional>
Optional Vector object to store the result in.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 189)
Returns:
Vector2 containing the coordinates of the curves end point.
- Type
- Phaser.Math.Vector2
-
getLength()
-
Get total curve arc length
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 206)
Returns:
The total length of the curve.
- Type
- number
-
getLengths( [divisions])
-
Get a list of cumulative segment lengths.
These lengths are
- [0] 0
- [1] The first segment
- [2] The first and second segment
- ...
- [divisions] All segments
Parameters:
Name Type Argument Description divisionsnumber <optional>
The number of divisions or segments.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 222)
Returns:
An array of cumulative lengths.
- Type
- Array.<number>
-
getPoint(t [, out])
-
Get point at relative position in curve according to length.
Parameters:
Name Type Argument Description tnumber The position along the curve to return. Where 0 is the start and 1 is the end.
outPhaser.Math.Vector2 <optional>
A Vector2 object to store the result in. If not given will be created.
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 133)
Returns:
The coordinates of the point on the curve. If an
outobject was given this will be returned.- Type
- Phaser.Math.Vector2
-
getPointAt(u [, out])
-
Gets a point at a given position on the line.
Parameters:
Name Type Argument Description unumber The position along the curve to return. Where 0 is the start and 1 is the end.
outPhaser.Math.Vector2 <optional>
A Vector2 object to store the result in. If not given will be created.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 162)
Returns:
The coordinates of the point on the curve. If an
outobject was given this will be returned.- Type
- Phaser.Math.Vector2
-
getPoints( [divisions] [, stepRate] [, out])
-
Get a sequence of evenly spaced points from the curve.
You can pass
divisions,stepRate, or neither.The number of divisions will be
divisions, ifdivisions> 0; orthis.getLength / stepRate, ifstepRate> 0; orthis.defaultDivisions
1 + divisionspoints will be returned.Parameters:
Name Type Argument Description divisionsnumber <optional>
The number of divisions to make.
stepRatenumber <optional>
The curve distance between points, implying
divisions.outarray | Array.<Phaser.Math.Vector2> <optional>
An optional array to store the points in.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 300)
Returns:
An array of Points from the curve.
- Type
- array | Array.<Phaser.Math.Vector2>
-
getRandomPoint( [out])
-
Get a random point from the curve.
Parameters:
Name Type Argument Description outPhaser.Math.Vector2 <optional>
A point object to store the result in.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 349)
Returns:
The point.
- Type
- Phaser.Math.Vector2
-
getResolution( [divisions])
-
Gets the resolution of the line.
Parameters:
Name Type Argument Default Description divisionsnumber <optional>
1 The number of divisions to consider.
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 116)
Returns:
The resolution. Equal to the number of divisions.
- Type
- number
-
getSpacedPoints( [divisions] [, stepRate] [, out])
-
Get a sequence of equally spaced points (by arc distance) from the curve.
1 + divisionspoints will be returned.Parameters:
Name Type Argument Default Description divisionsnumber <optional>
this.defaultDivisions The number of divisions to make.
stepRatenumber <optional>
Step between points. Used to calculate the number of points to return when divisions is falsy. Ignored if divisions is positive.
outarray | Array.<Phaser.Math.Vector2> <optional>
An optional array to store the points in.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 370)
Returns:
An array of points.
- Type
- Array.<Phaser.Math.Vector2>
-
getStartPoint( [out])
-
Gets the starting point on the curve.
Parameters:
Name Type Argument Description outPhaser.Math.Vector2 <optional>
A Vector2 object to store the result in. If not given will be created.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 97)
Returns:
The coordinates of the point on the curve. If an
outobject was given this will be returned.- Type
- Phaser.Math.Vector2
-
getTangent()
-
Gets the slope of the line as a unit vector.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 180)
Returns:
The tangent vector.
- Type
- Phaser.Math.Vector2
-
getTangentAt(u [, out])
-
Get a unit vector tangent at a relative position on the curve, by arc length.
Parameters:
Name Type Argument Description unumber The relative position on the curve, [0..1].
outPhaser.Math.Vector2 <optional>
A vector to store the result in.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 472)
Returns:
The tangent vector.
- Type
- Phaser.Math.Vector2
-
getTFromDistance(distance [, divisions])
-
Given a distance in pixels, get a t to find p.
Parameters:
Name Type Argument Description distancenumber The distance, in pixels.
divisionsnumber <optional>
Optional amount of divisions.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 492)
Returns:
The distance.
- Type
- number
-
getUtoTmapping(u, distance [, divisions])
-
Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant.
Parameters:
Name Type Argument Description unumber A float between 0 and 1.
distancenumber The distance, in pixels.
divisionsnumber <optional>
Optional amount of divisions.
- Since: 3.0.0
- Overrides:
- Source: src/curves/LineCurve.js (Line 197)
Returns:
The equidistant value.
- Type
- number
-
toJSON()
-
Gets a JSON representation of the line.
- Since: 3.0.0
- Source: src/curves/LineCurve.js (Line 256)
Returns:
The JSON object containing this curve data.
-
updateArcLengths()
-
Calculate and cache the arc lengths.
- Since: 3.0.0
- Inherited From:
- Source: src/curves/Curve.js (Line 594)
- See:
-
- Phaser.Curves.Curve#getLengths()
