|
@@ -54,6 +54,9 @@ class Layers extends Object {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Moves Object to the bottom of its layer (rendered first, behind the other Objects in layer).
|
|
|
+ **/
|
|
|
public function under( s : Object ) {
|
|
|
for( i in 0...children.length )
|
|
|
if( children[i] == s ) {
|
|
@@ -69,10 +72,16 @@ class Layers extends Object {
|
|
|
p--;
|
|
|
}
|
|
|
children[pos] = s;
|
|
|
- break;
|
|
|
+ // Force Interactive to reattach to scene in order to keep interaction order.
|
|
|
+ if ( s.allocated )
|
|
|
+ s.onHierarchyMoved(false);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Moves Object to the top of its layer (rendered last, in front of other Objects in layer).
|
|
|
+ **/
|
|
|
public function over( s : Object ) {
|
|
|
for( i in 0...children.length )
|
|
|
if( children[i] == s ) {
|
|
@@ -81,12 +90,20 @@ class Layers extends Object {
|
|
|
for( p in i...l-1 )
|
|
|
children[p] = children[p + 1];
|
|
|
children[l - 1] = s;
|
|
|
- break;
|
|
|
+ // Force Interactive to reattach to scene in order to keep interaction order.
|
|
|
+ if ( s.allocated )
|
|
|
+ s.onHierarchyMoved(false);
|
|
|
+ return;
|
|
|
}
|
|
|
- break;
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Returns Iterator of objects contained in specified layer.
|
|
|
+ Returns empty iterator if layer does not exists.
|
|
|
+ Objects added or removed from Layers during iteration are not added/removed from the Iterator.
|
|
|
+ **/
|
|
|
public function getLayer( layer : Int ) : Iterator<Object> {
|
|
|
var a;
|
|
|
if( layer >= layerCount )
|
|
@@ -99,6 +116,19 @@ class Layers extends Object {
|
|
|
return new hxd.impl.ArrayIterator(a);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Finds the layer on which child object resides.
|
|
|
+ Always returns -1 if provided Object is not a child of Layers.
|
|
|
+ **/
|
|
|
+ public function getChildLayer( s : Object ) : Int {
|
|
|
+ if ( s.parent != this ) return -1;
|
|
|
+
|
|
|
+ var index = children.indexOf(s);
|
|
|
+ for ( i in 0...layerCount )
|
|
|
+ if ( layersIndexes[i] > index ) return i;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
function drawLayer( ctx : RenderContext, layer : Int ) {
|
|
|
if( layer >= layerCount )
|
|
|
return;
|
|
@@ -114,6 +144,9 @@ class Layers extends Object {
|
|
|
ctx.globalAlpha = old;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ Sorts specified layer based on Y value of it's Objects.
|
|
|
+ **/
|
|
|
public function ysort( layer : Int ) {
|
|
|
if( layer >= layerCount ) return;
|
|
|
var start = layer == 0 ? 0 : layersIndexes[layer - 1];
|
|
@@ -133,6 +166,8 @@ class Layers extends Object {
|
|
|
p--;
|
|
|
}
|
|
|
children[p + 1] = c;
|
|
|
+ if ( c.allocated )
|
|
|
+ c.onHierarchyMoved(false);
|
|
|
} else
|
|
|
ymax = c.y;
|
|
|
pos++;
|