The IsOn3D method is a very powerful method that can be used to test if the cursor is over an object. IsOn3D is used by Glue generated code to test if the Cursor is over an Entity if the Entity implements IClickable or IWindow. The IsOn3D method is very powerful and flexible. It considers:
Object position
Camera position
Object orientation
Camera orientation
Camera perspective settings
Layers
It can be used to check if the cursor is over any of the following objects:
Sprite
Text
AxisAlignedCube
Sphere
Any other object implementing IPositionable, IScalable, IRotatable
The following code creates a group of Sprites which turn invisible when the cursor moves over them. Add the following at class scope:
Add the following in Initialize after initializing FlatRedBall:
Add the following to Update:
The IsOn3D method can be used to detect if the Cursor has clicked on an object. For example, the following code shows how to check if the user has clicked on a Sprite:
For more information on PrimaryClick, see the PrimaryClick page.
The IsOn3D method supports Layers as well. For example, assuming mySprite is a valid Sprite and myLayer is valid Layer: