Last updated
Was this helpful?
Last updated
Was this helpful?
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.
The following sample creates a line, a , and an . 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:
Add the following in Initialize after Initializing FlatRedBall:
Lines must be one pixel thick. Thicker lines are not supported.
Lines can only draw solid colors - patterns and gradients are not supported.
Note that FlatRedBall expects shape colors to be pre-multiplied. Therefore a half-transparent red value would have a R,G,B,A value of (128,0,0,128).
A line can be modified by changing both its properties as well as through the RelativePoint property. The following code connects two rectangles with a line. Add the following in Update:
Lines, just like any other , can either be drawn on top of or below types that can sort with each other, such as and . They will not sort according to their Z value.