/** Updates the height of this group layer, and hence its clipping rectangle. */ public ClippedLayer setHeight(float height) { this.height = height; checkOrigin(); return this; }
@Override protected final void paintImpl (Surface surf) { if (disableClip()) paintClipped(surf); else { Transform tx = surf.tx(); float originX = originX(), originY = originY(); tx.translate(originX, originY); tx.transform(pos.set(-originX, -originY), pos); tx.transform(size.set(width, height), size); tx.translate(-originX, -originY); if (size.x < 0) { size.x = -size.x; pos.x -= size.x; } if (size.y < 0) { size.y = -size.y; pos.y -= size.y; } boolean nonEmpty = surf.startClipped( (int)pos.x, (int)pos.y, Math.round(size.x), Math.round(size.y)); try { if (nonEmpty) paintClipped(surf); } finally { surf.endClipped(); } } }
@Override public void close() { super.close(); disposeAll(); }
@Override void onAdd() { super.onAdd(); for (int ii = 0, ll = children.size(); ii < ll; ii++) children.get(ii).onAdd(); }
@Override void onRemove() { super.onRemove(); for (int ii = 0, ll = children.size(); ii < ll; ii++) children.get(ii).onRemove(); }
@Override public Layer hitTestDefault(Point point) { float x = point.x, y = point.y; boolean sawInteractiveChild = false; // we check back to front as children are ordered "lowest" first for (int ii = children.size()-1; ii >= 0; ii--) { Layer child = children.get(ii); if (!child.interactive()) continue; // ignore non-interactive children sawInteractiveChild = true; // note that we saw an interactive child if (!child.visible()) continue; // ignore invisible children try { // transform the point into the child's coordinate system child.transform().inverseTransform(point.set(x, y), point); point.x += child.originX(); point.y += child.originY(); Layer l = child.hitTest(point); if (l != null) return l; } catch (NoninvertibleTransformException nte) { // Degenerate transform means no hit continue; } } // if we saw no interactive children and we don't have listeners registered directly on this // group, clear our own interactive flag; this lazily deactivates this group after its // interactive children have been deactivated or removed if (!sawInteractiveChild && !hasEventListeners()) setInteractive(false); return super.hitTestDefault(point); }
game.rootLayer.addAt(clayer.setOrigin(100, 100), 130, 130);
/** Updates the size of this clipped layer, and hence its clipping rectangle. */ public ClippedLayer setSize (float width, float height) { this.width = width; this.height = height; checkOrigin(); return this; }
/** Updates the width of this group layer, and hence its clipping rectangle. */ public ClippedLayer setWidth(float width) { this.width = width; checkOrigin(); return this; }