AbsoluteRightXEdgeAt
Introduction
The "absolute edge" methods return the edge of the visible area at a given Z. There are four such methods:
AbsoluteRightXEdgeAt
AbsoluteLeftXEdgeAt
AbsoluteTopYEdgeAt
AbsoluteBottomYEdgeAt
Z value argument
The absolute functions take a single argument - the Z value where the absolute values should be calculated. The reason this is necessary is because 3D cameras (by definition) use perspective. Therefore, the edge of the Camera changes as you move further away from the Camera. If you are positioning an object along the edges of the Camera, you will most likely want to use the Z of the object you are positioning as the argument to absolute functions. For an example, see the code in the section below.
Code Example
The following code creates four Circles. Each one is colored differently to help identify it.
Detecting if an object is on screen
The edge values can be used to check if on screen. For example, the following code checks if a character's point is on screen. Since visual objects are usually larger than a single pixel, an additional buffer can be added.
Note that the buffer value above may be required if your object does not have a Width property (such as if your object is an entity). If your object has a Width and Height property, like a Sprite, you can use that value as shown in the following code:
Edge values and attachments
If your Camera is attached to another object, you may need to call FlatRedBall.Camera.ForceUpdateDependencies before asking the Camera for its absolute edge values. For example:
Last updated