Line
Introduction
A line is defined by two endpoints, so in mathematical terms it is actually a segment. Lines can be used to perform 2D collisions against any other shapes.
Line Sample
The following sample creates a line, a Circle, and an AxisAlignedRectangle. The line is controlled with the keyboard and it changes colors when it collides with the other two shapes. Add the following using statements:
Add the following at class scope:
Add the following in Initialize after Initializing FlatRedBall:
Add the following in Update:
RelativePoint Properties
A line can be modified by changing both its PositionedObject properties as well as through the RelativePoint property. The following code connects two rectangles with a line. Add the following in Update:
Add the following in Initialize after Initializing FlatRedBall:
Line limitations
Lines must be one pixel thick. Thicker lines are not supported.
Lines can only draw solid colors - patterns and gradients are not supported.
Last updated