githubEdit

IsOn3d

Introduction

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 Gluearrow-up-right 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

Code Example

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:

CursorIsOn3D.png

IsOn3D for clicking UI

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 pagearrow-up-right.

IsOn3D and Layers

The IsOn3D method supports Layersarrow-up-right as well. For example, assuming mySprite is a valid Sprite and myLayer is valid Layer:

Last updated

Was this helpful?