A layer-based container for Objects.
Hierarchically organizes objects based on their layer.
Supports per-layer Y-sorting through Layers.ysort
.
Constructor
new(?parent:Object)
Create a new Layers instance.
Parameters:
parent | An optional parent |
---|
Methods
inlineadd(s:Object, layer:Int):Void
Adds a child object s
at the end of the given layer
.
h2d.Layers.addChildAt
can be used as an alternative.
Parameters:
s | An object to be added. |
---|---|
layer | An index of the layer, 0 is the bottom-most layer. |
addChild(s:Object):Void
Adds a child object s
at the end of the layer 0.
Parameters:
s | An object to be added. |
---|
addChildAt(s:Object, layer:Int):Void
Adds a child object s
at the end of the given layer
.
h2d.Layers.addChildAt
can be used as an alternative.
Parameters:
s | An object to be added. |
---|---|
layer | An index of the layer, 0 is the bottom-most layer. |
getChildLayer(s:Object):Int
Returns the layer on which the child s
resides on.
Parameters:
s | An object to look up to. |
---|
Returns:
An index of the layer where the object resides on or -1
if s
is not a child of the Layers.
getLayer(layer:Int):Iterator<Object>
Returns an Iterator with objects in a specified layer
.
Returns an empty iterator if no objects are present in the layer.
Objects added or removed from Layers during iteration do not affect the output of the Iterator.
Parameters:
layer | A layer index to iterate over. |
---|
over(s:Object):Void
Moves an object s
to the top of its layer (rendered last, in front of other Objects in layer).
Causes Object.onHierarchyMoved
on the Object.
Parameters:
s | An object to be moved. |
---|
under(s:Object):Void
Moves an object s
to the bottom of its layer (rendered first, behind the other Objects in the layer).
Causes Object.onHierarchyMoved
on the Object.
Parameters:
s | An object to be moved. |
---|
ysort(layer:Int):Void
Sorts specified layer based on Object.y
value of it's children.
Causes Object.onHierarchyChanged
on moved children.
Parameters:
layer | An index of the layer to sort. |
---|