Ejemplo n.º 1
0
  public void update(int elapsedTime) {
    cursor.setLocation(Input.getMouseX(), Input.getMouseY());
    cursor.visible.set(Input.isMouseInside());

    if (Input.isMousePressed()) {
      maskLayer.visible.toggle();
      setCursor(maskLayer.visible.get() ? Input.CURSOR_OFF : Input.CURSOR_DEFAULT);
    }
  }
Ejemplo n.º 2
0
 Sprite makeParticle() {
   CoreImage image = CoreImage.load("particle.png");
   int color = hue(rand(0, 255));
   final ImageSprite sprite = new ImageSprite(image.tint(color), 0, 0);
   sprite.setAnchor(0.5, 0.5);
   sprite.pixelSnapping.set(true);
   Blur blur = new Blur(8);
   blur.quality.set(1);
   blur.radius.bindTo(
       new BindFunction() {
         public Number f() {
           int w = Stage.getWidth() / 2;
           double f = 1 - Math.abs(w - sprite.x.get()) / w;
           if (f < 0.10) {
             return 0;
           } else {
             return 16 * (f - 0.10);
           }
         }
       });
   sprite.setFilter(blur);
   return sprite;
 }
Ejemplo n.º 3
0
  public void load() {
    setCursor(Input.CURSOR_OFF);
    cursor = new ImageSprite("glow.png", 0, 0);
    cursor.setAnchor(0.5, 0.5);
    cursor.visible.set(false);

    // Create the mask
    maskLayer = new Group();
    maskLayer.add(new FilledSprite(gray(18)));
    maskLayer.add(cursor);
    maskLayer.setBlendMode(BlendMode.Multiply());
    maskLayer.createBackBuffer();

    // Create the background image
    Timeline t = new Timeline();
    Group imageLayer = new Group();
    imageLayer.add(new FilledSprite(rgb(0xba9b65)));
    int size = 80;
    int spacing = 16;
    for (int i = -spacing / 2; i < Stage.getWidth(); i += spacing + size) {
      for (int j = -spacing / 2; j < Stage.getHeight(); j += spacing + size) {
        int color1 = colors[CoreMath.rand(colors.length - 1)];
        int color2 = colors[CoreMath.rand(colors.length - 1)];
        FilledSprite sprite = new FilledSprite(i, j, size, size, color1);
        imageLayer.add(sprite);
        int delay1 = CoreMath.rand(20000);
        int delay2 = delay1 + CoreMath.rand(20000);
        t.set(sprite.fillColor, color2, delay1);
        t.set(sprite.fillColor, color1, delay2);
      }
    }
    t.loopForever();
    addTimeline(t);

    // Add the layers to the scene
    addLayer(imageLayer);
    addLayer(maskLayer);
  }