IgeObject

Method: depth

Gets / sets the current render depth of the object (higher depths are drawn over lower depths). Please note that entities are first sorted by their layer and then by their depth, and only entities of the same layer will be sorted against each other by their depth values.
depth (Number val)
  • Numberval
Returns * Returns this when setting the value or the current value if none is specified.

Set an entity's depth to 1

var entity = new IgeEntity()
    .depth(1);

Get an entity's depth value

var entity = new IgeEntity()
console.log(entity.depth());

How layers and depths are handled together

var entity1 = new IgeEntity(),
    entity2 = new IgeEntity(),
    entity3 = new IgeEntity();
// Set entity1 to at layer zero and depth 100
entity1.layer(0)
    .depth(100);
// Set entity2 and 3 to be at layer 1
entity2.layer(1);
entity3.layer(1);
// Set entity3 to have a higher depth than entity2
entity2.depth(0);
entity3.depth(1);
// The engine sorts first based on layer from lowest to highest
// and then within each layer, by depth from lowest to highest.
// This means that entity1 will be drawn before entity 2 and 3
// because even though it's depth is higher, it is not on the same
// layer as entity 2 and 3.
// Based on the layers and depths we have assigned, here
// is how the engine will sort the draw order of the entities
// entity1
// entity2
// entity3
© Copyright 2013 Irrelon Software Limited. All Rights Reserved. UK Registered Company Number: 07522767
Isogenic (ī´sōjen´ik): Adj originating from a common source; possessing the same genetic composition.
Strange Things Happen at the One Two Point