return this;
}
@Override protected Instance instantiate (final IDimension size) {
// we use one layer, and add the constituents to that
GroupLayer layer = PlayN.graphics().createGroupLayer();
final Instance[] instances = new Instance[_constituents.length];
Insets current = Insets.ZERO;
for (int ii = 0, ll = _constituents.length; ii < ll; ii++) {
Background bg = _constituents[ii];
// create and save off the instance so we can destroy it later
instances[ii] = instantiate(bg, current.subtractFrom(new Dimension(size)));
// add to our composite layer and translate the layers added
instances[ii].addTo(layer, current.left(), current.top(), 0);
// adjust the bounds
current = current.mutable().add(bg.insets);
}
if (_reverseDepth) {
// simple reversal, if optimization is needed it would be better to simply
// instantiate the backgrounds in reverse order above
Layer[] temp = new Layer[layer.size()];
for (int ii = 0, nn = layer.size(); ii < nn; ii++) {
temp[ii] = layer.get(ii);
}
float depth = 0;
for (Layer l : temp) {
l.setDepth(depth);
depth -= 1;