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 - Creating Circles at Camera Edges
The following code creates four Circles. Each one is colored differently to help identify it.
Code Example - Setting Camera Edges
The absolute edge values can be assigned if your Camera is 2D (Orthogonal = true). For example, the following code sets the Camera's top left corner to the origin. Keep in mind that positive Y still points up.
If your Camera's Orthogonal value is set to false, then setting any of the absolute values results in an exception being thrown.
Setting any othe absolute values ultimately assigns the Camera's X and Y properties. If your Camera is attached to another object or if you are using a CameraControllingEntity, then these position changes will be undone when updates are processed.
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
Last updated
Was this helpful?