Package playn.core

Examples of playn.core.GroupLayer


        });
        bg.setDepth(-1);
        layer.add(bg);

        // test our simple frames
        final GroupLayer box = graphics().createGroupLayer();
        layer.addAt(box, 0, 100);
        Image image = assets().getImage("images/spritesheet.png");
        image.addCallback(new Callback<Image>() {
            public void onSuccess (Image image) {
                SimpleFrames frames = new SimpleFrames(image, 60, 60, 60);
                anim.repeat(box).flipbook(box, new Flipbook(frames, 66));
                anim.repeat(box).tweenX(box).to(width-frames.width()).in(2000).easeInOut().then().
                    tweenX(box).to(0).in(2000).easeInOut();
            }
            public void onFailure (Throwable error) {} // n/a
        });

        // test our packed frames
        final Image packed = assets().getImage("images/packed.png");
        assets().getText("images/packed.json", new Callback<String>() {
            public void onSuccess (String json) {
                GroupLayer box = graphics().createGroupLayer();
                layer.addAt(box, 100, 200);
                anim.repeat(box).flipbook(
                    box, new Flipbook(new PackedFrames(packed, json().parse(json)), 99)).then().
                    setVisible(box, false).then().delay(500).then().setVisible(box, true);
            }

            public void onFailure (Throwable t) {
                t.printStackTrace(System.err);
            }
        });
        GroupLayer pbox = graphics().createGroupLayer();
        layer.addAt(pbox, 300, 200);
        anim.repeat(pbox).flipbook(
            pbox, new Flipbook(new PackedFrames(packed, PACKED), 99)).then().
            setVisible(pbox, false).then().delay(500).then().setVisible(pbox, true);
View Full Code Here


    /**
     * Creates a new group with the given children.
     */
    public static GroupLayer group (Layer... children) {
        GroupLayer gl = PlayN.graphics().createGroupLayer();
        for (Layer l : children) gl.add(l);
        return gl;
    }
View Full Code Here

        concatTransform(canvas, layer.transform());
        canvas.translate(-layer.originX(), -layer.originY());

        float nalpha = alpha * layer.alpha();
        if (layer instanceof GroupLayer) {
            GroupLayer gl = (GroupLayer)layer;
            for (int ii = 0, ll = gl.size(); ii < ll; ii++) {
                capture(gl.get(ii), canvas, nalpha);
            }

        } else if (layer instanceof ImageLayer) {
            ImageLayer il = (ImageLayer)layer;
            canvas.setAlpha(nalpha);
View Full Code Here

                bounds.add(Layer.Util.layerToParent(l, root, scratch.set(w, h), scratch));
            }
        }

        if (l instanceof GroupLayer) {
            GroupLayer group = (GroupLayer) l;
            for (int ii = 0, ll = group.size(); ii < ll; ++ii) {
                addBounds(root, group.get(ii), bounds, scratch);
            }
        }
    }
View Full Code Here

        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;
View Full Code Here

        }

        protected void setCurrent (Instance current) {
            if (_current != current) {
                _current = current;
                GroupLayer group = (GroupLayer)content;
                group.removeAll();
                group.add(current.layer());
            }
        }
View Full Code Here

     * Starts a flipbook animation that displays the supplied {@code book} at the specified
     * position in the supplied parent. The intermediate layers created to display the flipbook
     * animation will be destroyed on completion.
     */
    public Animation flipbookAt (GroupLayer parent, float x, float y, Flipbook book) {
        GroupLayer box = graphics().createGroupLayer();
        box.setTranslation(x, y);
        return add(parent, box).then().flipbook(box, book).then().destroy(box);
    }
View Full Code Here

            this.tx = tx;
            this.ty = ty;
        }

        @Override public Layer render () {
            GroupLayer layer = PlayN.graphics().createGroupLayer();
            layer.addAt(super.render(), tx, ty);
            return layer;
        }
View Full Code Here

    return min + (int) (Math.random() * ((max - min) + 1));
  }

  public void drawTransparentImageLayers() {
      // THIS WORKS
    GroupLayer groupLayer = graphics().createGroupLayer();
    groupLayer.add(bgLayer);
    groupLayer.add(redCircle.asImageLayer());
    groupLayer.add(whiteCircle.asImageLayer());
    groupLayer.add(blueCircle.asImageLayer());
    rootLayer.add(groupLayer);
  }
View Full Code Here

      PlayN.log().info(message);
      logMessages.addFirst(message);
  }
 
  public static void displayLog() {
      GroupLayer logLayer = graphics().createGroupLayer();
     
      // generate log message images
      int logSize = (logMessages.size() >= logDisplayLength) ? logDisplayLength : logMessages.size();
      logCount = 0;
     
      for (int n=0; n<logSize; n++) {
          logCount++;
          String message = logMessages.get(n);
          ImageLayer messageImage = generateLogMessageImageLayer(message);
          Number screenY = logScreenPos.y + (n * (logFontSize + 4));
          messageImage.transform().translate(logScreenPos.x, screenY.floatValue());
          logLayer.add(messageImage);
      }
     
      graphics().rootLayer().add(logLayer);
  }
View Full Code Here

TOP

Related Classes of playn.core.GroupLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.