Introduction The IsPointInside method returns whether an absolute X/Y position is inside the calling Polygon. This function takes 3D position objects (such as Vector3) but ignores the Z value. Only X and Y are considered. Code Example The following code creates a Polygon that is in the shape of a rectangle. When the user moves[…]


Introduction All FlatRedBall shapes inherit from the PositionedObject class, so they inherit the X, Y, Z, and Position properties. The Z value of shapes impacts their rendering, but not collision. In other words, shapes will render differently according to their Z value when rendering on a 3D camera, but they will collide as if their[…]


Introduction The Color property lets you set the color of a Polygon. Code Example The following code shows how to set a Polygon to a color: // Assuming PolygonInstance is a valid Polygon PolygonInstance.Color = Color.Red; Premultiplied Colors If the engine uses premultiplied alpha, then you must provide premultiplied alpha colors if using transparency.


Introduction The Polygon class overrides the base ForceUpdateDependencies implementation. The Polygon’s ForceUpdateDependencies method does the same thing as the base ForceUpdateDependencies implementation (updates the instance’s absolute Position and Rotation values according to attachments); however, it *also* updates the Polygon’s internal vertices. When should ForceUpdateDependencies be called? In most situations you will not need to call[…]


Introduction The Clone method can be used to create a copy of a given Polygon. A cloned polygon will be identical to the original polygon. Cloned polygons can be used if you are loading Polygons from a file and want to create multiple instances of a given Polygon. For example, you may create a Polygon[…]


Introduction The ScaleBy method can be used to adjust a Polygon’s points to make it larger or smaller. The ScaleBy method is relative to the current state of the polygon. This means that calling ScaleBy with any number other than 1 multiple times will continually change the polygon. Scaling multiple times Calling ScaleBy multiple times[…]


Introduction The CreateEquilateral static method is a method in the Polygon class which can be used to quickly create equilateral (same-length sides) Polygons. Code Example The following code creates two Polygons. One is a 4-sided polygon. The other one is a very high-vertex count Polygon which can be used to draw smooth Circles. Keep in[…]


Introduction The Visible property controls whether a particular shape is drawn. Setting Visible to false will make a shape no longer be drawn. Setting Visible to true will make the shape drawn – even if it is not part of the ShapeManager. Under the hood All visible shapes are stored in lists in the ShapeManager[…]


Introduction The OptimizeRadius method can be called to adjust the relative points of a Polygon to reduce its radius. The radius of a polygon is used internally to improve the performance of collision methods. Usage The OptimizeRadius method should be called if a Polygon’s points are set or changed. This method will adjust the values[…]


Introduction The CollideAgainstBounce is a collision method which performs the following: Returns true if a collision has occurred. Repositions the calling Circle and/or the argument object depending on the argument masses. Changes the calling Shape’s Velocity and/or the argument object’s Velocity depending on the argument masses. Note: All collision methods, including CollideAgainstBounce, are methods common[…]