Class: Line

Phaser. Line

Phaser - Line

new Line(x1, y1, x2, y2) → {Phaser.Line}

Creates a new Line object with a start and an end point.

Parameters:
Name Type Argument Default Description
x1 number <optional>
0

The x coordinate of the start of the line.

y1 number <optional>
0

The y coordinate of the start of the line.

x2 number <optional>
0

The x coordinate of the end of the line.

y2 number <optional>
0

The y coordinate of the end of the line.

Source:
Returns:

This line object

Type
Phaser.Line

Members

<readonly> angle

Properties:
Name Type Description
angle number

Gets the angle of the line.

Source:

end

Properties:
Name Type Description
end Phaser.Point

The end point of the line.

Source:

<readonly> length

Properties:
Name Type Description
length number

Gets the length of the line segment.

Source:

<readonly> perpSlope

Properties:
Name Type Description
perpSlope number

Gets the perpendicular slope of the line (x/y).

Source:

<readonly> slope

Properties:
Name Type Description
slope number

Gets the slope of the line (y/x).

Source:

start

Properties:
Name Type Description
start Phaser.Point

The start point of the line.

Source:

Methods

<static> intersects(a, b, asSegment, result) → {Phaser.Point}

Checks for intersection between two lines. If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. Adapted from code by Keith Hair

Parameters:
Name Type Argument Default Description
a Phaser.Line

The first Line to be checked.

b Phaser.Line

The second Line to be checked.

asSegment boolean <optional>
true

If true it will check for segment intersection, otherwise full line intersection.

result Phaser.Point <optional>

A Point object to store the result in, if not given a new one will be created.

Source:
Returns:

The intersection segment of the two lines as a Point, or null if there is no intersection.

Type
Phaser.Point

<static> intersectsPoints(a, b, e, f, asSegment, result) → {Phaser.Point}

Checks for intersection between two lines as defined by the given start and end points. If asSegment is true it will check for line segment intersection. If asSegment is false it will check for line intersection. Returns the intersection segment of AB and EF as a Point, or null if there is no intersection. Adapted from code by Keith Hair

Parameters:
Name Type Argument Default Description
a Phaser.Point

The start of the first Line to be checked.

b Phaser.Point

The end of the first line to be checked.

e Phaser.Point

The start of the second Line to be checked.

f Phaser.Point

The end of the second line to be checked.

asSegment boolean <optional>
true

If true it will check for segment intersection, otherwise full line intersection.

result Phaser.Point <optional>

A Point object to store the result in, if not given a new one will be created.

Source:
Returns:

The intersection segment of the two lines as a Point, or null if there is no intersection.

Type
Phaser.Point

fromSprite(startSprite, endSprite, useCenter) → {Phaser.Line}

Sets the line to match the x/y coordinates of the two given sprites. Can optionally be calculated from their center coordinates.

Parameters:
Name Type Argument Default Description
startSprite Phaser.Sprite

The coordinates of this Sprite will be set to the Line.start point.

endSprite Phaser.Sprite

The coordinates of this Sprite will be set to the Line.start point.

useCenter boolean <optional>
true

If true it will use startSprite.center.x, if false startSprite.x.

Source:
Returns:

This line object

Type
Phaser.Line

intersects(line, asSegment, result) → {Phaser.Point}

Checks for intersection between this line and another Line. If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection. Returns the intersection segment of AB and EF as a Point, or null if there is no intersection.

Parameters:
Name Type Argument Default Description
line Phaser.Line

The line to check against this one.

asSegment boolean <optional>
true

If true it will check for segment intersection, otherwise full line intersection.

result Phaser.Point <optional>

A Point object to store the result in, if not given a new one will be created.

Source:
Returns:

The intersection segment of the two lines as a Point, or null if there is no intersection.

Type
Phaser.Point

pointOnLine(x, y) → {boolean}

Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.

Parameters:
Name Type Description
x number

The line to check against this one.

y number

The line to check against this one.

Source:
Returns:

True if the point is on the line, false if not.

Type
boolean

pointOnSegment(x, y) → {boolean}

Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.

Parameters:
Name Type Description
x number

The line to check against this one.

y number

The line to check against this one.

Source:
Returns:

True if the point is on the line and segment, false if not.

Type
boolean

setTo(x1, y1, x2, y2) → {Phaser.Line}

Sets the components of the Line to the specified values.

Parameters:
Name Type Argument Default Description
x1 number <optional>
0

The x coordinate of the start of the line.

y1 number <optional>
0

The y coordinate of the start of the line.

x2 number <optional>
0

The x coordinate of the end of the line.

y2 number <optional>
0

The y coordinate of the end of the line.

Source:
Returns:

This line object

Type
Phaser.Line
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Mon Feb 24 2014 12:11:41 GMT-0000 (GMT) using the DocStrap template.