Points
Introduction
The Points property is an array of Point values which contain the position of each point on the polygon. These values are in "object space". In other words, they are relative to the containing Polygon's position and rotation values.
The Points property can be assigned - this essentially changes the shape of the Polygon. This is a more-efficient and often more-convenient way to change a Polygon rather than to construct a new one if your game requires dynamic shapes. For more information, see this section.
Code Example - Setting Points
Code Example - Getting absolute Point positions
The values in the Points array are all relative to the containing Polygon. This means that if the Polygon moves or rotates, the values stored in the Points property will remain the same.
To retrieve the absolute position of each Point, the relative points must be converted into world (or absolute) coordinates.
The following code creates a Polygon which spins automatically and is repositioned based off of Keyboard activity. Three Sprites are positioned in the world coordinates of each of the Polygon's points in the Update method. Since the Sprites are being positioned in world space, the position of the points must be converted to world space so that the Sprites appear in the proper position.
Add the following using statements:
Add the following at class scope:
Add the following in Initialize after initializing FlatRedBall:
Add the following in Update:
Last updated