Z
Introduction
The Z property controls the absolute Z position of an object. On 3D cameras (Orthogonal=false) , the smaller the Z is, the further away from the camera an object will appear. For information on setting Z in the FlatRedBall Editor, see this page.
Code Example
The following code assumes an empty Screen, and the code is written in CustomInitialize.
Z in 2D
The Z value controls the distance of an object from the Camera. When using a 2D Camera (Orthogonal=true), changing the Z will not make objects get bigger or smaller as they move closer to/away from the Camera. Despite that, the Z value still impacts a few things:
Objects with a Z value smaller than the Camera's near clip plane (by default 39) will not be drawn
Objects with a Z value larger than the Camera's far clip plane (by default -960) will not be drawn
Objects will sort with each other according to their Z values (excluding shapes like Circle and AxisAlignedRectangle)
Default values
SpriteManager.Camera.Z = 40
New PositionedObject.Z = 0
Z and Sorting
For information about how Z affects sorting, see the SpriteManager.OrderedSortType property documents.
Last updated