IsPointInside
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 the cursor in the polygon it turns red; otherwise it is yellow.
Add the following using statements:
Define the Polygon at class scope:
Add the following in Initializing after initializing FlatRedBall (or CustomInitialize if using Screens):
Add the following in Update (or CustomActivity if using Screens):
IsPointInside and ForceUpdateDependencies
The IsPointInside method requires that the Polygon has constructed its internal vertices. This means that you must either:
If neither of the above has happened, then the internal vertices will not be set and this function will always return false.
Last updated
Was this helpful?