//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011-2012, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.demo.anim;

import java.util.Random;

import playn.core.CanvasImage;
import playn.core.ImageLayer;
import playn.core.Font;
import static playn.core.PlayN.*;
import playn.core.Pointer;

import tripleplay.demo.DemoScreen;
import tripleplay.ui.Group;
import tripleplay.util.TextConfig;

public class AnimDemo extends DemoScreen
{
    @Override protected String name () {
        return "Anims";
    }
    @Override protected String title () {
        return "Various Animations";
    }

    @Override protected Group createIface () {
        // demo a repeating animation
        CanvasImage image = graphics().createImage(100, 100);
        image.canvas().setFillColor(0xFFFFCC99);
        image.canvas().fillCircle(50, 50, 50);
        ImageLayer circle = graphics().createImageLayer(image);

        float width = graphics().width();
        anim.addAt(layer, circle, 50, 100).then().
            repeat(circle).tweenX(circle).to(width-150).in(1000).easeInOut().then().
            tweenX(circle).to(50).in(1000).easeInOut();

        // demo the shake animation
        final ImageLayer click = CFG.toLayer("Click to Shake");
        click.addListener(new Pointer.Adapter() {
            public void onPointerStart (Pointer.Event event) {
                anim.shake(click, RAND).bounds(-3, 3, -3, 0).cycleTime(25, 25).in(1000);
            }
        });
        layer.addAt(click, (width-click.width())/2, 275);

        return null;
    }

    protected static final Random RAND = new Random();
    protected static final TextConfig CFG = new TextConfig(0xFF000000).
        withFont(graphics().createFont("Helvetica", Font.Style.PLAIN, 48));
}

@@ -234,26 +234,31 @@
 ort 
-java.util.Random;%0A
+playn.core.CanvasImage;
 %0Aimp
@@ -268,35 +268,28 @@
  playn.core.
-CanvasImage
+Font
 ;%0Aimport pla
@@ -318,36 +318,39 @@
 port playn.core.
-Font
+Pointer
 ;%0Aimport static 
@@ -372,35 +372,8 @@
 N.*;
-%0Aimport playn.core.Pointer;
 %0A%0Aim
@@ -1461,14 +1461,8 @@
 lick
-, RAND
 ).bo
@@ -1625,63 +1625,8 @@
  %7D%0A%0A
-    protected static final Random RAND = new Random();%0A
     

Update demo, nix secret RNG.