protected Layer createWhiteBackground() { Layer bg = new Layer() { protected void paintImpl (Surface surf) { surf.setFillColor(0xFFFFFFFF).fillRect( 0, 0, graphics.viewSize.width(), graphics.viewSize.height()); } }; bg.setDepth(Float.NEGATIVE_INFINITY); // render behind everything return bg; } }
return action(new Runnable() { public void run () { layer.setDepth(depth); }}); }
protected void add (Emitter emitter) { layer.add(emitter.layer.setDepth(1)); _emitters.add(emitter); }
@Override public void addTo (GroupLayer parent, float x, float y, float depthAdjust) { _layer.setDepth(BACKGROUND_DEPTH + depthAdjust); _layer.transform().translate(x, y); // adjust any existing transform parent.add(_layer); } @Override public void close () {
@Override protected void layout (LayoutData ldata, float left, float top, float width, float height) { // set the bars and element buffer first so the ScrollLayout can use them _elementBuffer = resolveStyle(ELEMENT_BUFFER); updateBars(((BarsLayoutData)ldata).barType); super.layout(ldata, left, top, width, height); if (_bars != null) layer.add(_bars.layer().setDepth(1).setTranslation(left, top)); }
l.setDepth(depth); depth -= 1;
@Override public void init () { Canvas bgcanvas = game.graphics.createCanvas(WIDTH + 10, HEIGHT); bgcanvas.setFillColor(0xff808080); bgcanvas.fillRect(0, 0, WIDTH + 10, HEIGHT); ImageLayer bg = new ImageLayer(bgcanvas.toTexture()); Canvas knob = game.graphics.createCanvas(WIDTH, HWIDTH); knob.setFillColor(0xffffffff).fillRect(0, 0, WIDTH, HWIDTH); knob.setStrokeColor(0xff000000).drawLine(0, HWIDTH / 2, WIDTH, HWIDTH / 2); knob.setStrokeColor(0xffff0000).strokeRect(0, 0, WIDTH - 1, HWIDTH - 1); ImageLayer il = new ImageLayer(knob.toTexture()); il.setOrigin(0, HWIDTH / 2).setDepth(1).setTranslation(0, HEIGHT / 2); GroupLayer slider = new GroupLayer(); slider.add(bg); slider.add(il); game.rootLayer.addAt(slider, 25, 25); bg.events().connect(new Mouse.Listener() { @Override public void onWheel (Mouse.WheelEvent event, Mouse.Interaction iact) { float y = il.ty() + event.velocity; y = Math.max(0, Math.min(y, HEIGHT)); il.setTranslation(0, y); } }); } }
layer.add(_thumb = thumbImage.render().setDepth(1)); if (thumbOrigin == null) { _thumb.setOrigin(thumbWidth/2, thumbHeight/2);
bg.setDepth(-1); layer.add(bg);