Phaser API Documentation

  Version: 
<static> LineToRectangle(line, rect)

Description:

Checks for intersection between the Line and a Rectangle shape, or a rectangle-like object, with public x, y, right and bottom properties, such as a Sprite or Body.

An intersection is considered valid if:

The line starts within, or ends within, the Rectangle. The line segment intersects one of the 4 rectangle edges.

The for the purposes of this function rectangles are considered 'solid'.

Parameters:

name type description
line Phaser.Geom.Line

The Line to check for intersection.

rect object | Phaser.Geom.Rectangle

The Rectangle to check for intersection.

Returns:
Description:

true if the Line and the Rectangle intersect, false otherwise.

Type:
  • boolean
Examples:
Since: 3.0.0