/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pulpcore.scene;

import pulpcore.Stage;

/**
 * Sliding transition
 *
 * @author eric
 */
public class SlideTransition extends TransitionScene {
    public static final int RIGHT = 0;
    public static final int LEFT = 1;
    public static final int UP = 2;
    public static final int DOWN = 3;
    private int direction = RIGHT;

    public SlideTransition direction(int newDirection) {
        direction = newDirection;
        return this;
    }

    protected void transitionStart() {
        if (direction == LEFT) {
            fromSprite.x.animate(0.0, Stage.getWidth(), duration, easing);
            toSprite.x.animate(-Stage.getWidth(), 0.0, duration, easing);
        } else if (direction == RIGHT) {
            fromSprite.x.animate(0.0, -Stage.getWidth(), duration, easing);
            toSprite.x.animate(Stage.getWidth(), 0.0, duration, easing);
        } else if (direction == UP) {
            fromSprite.y.animate(0.0, Stage.getHeight(), duration, easing);
            toSprite.y.animate(-Stage.getHeight(), 0.0, duration, easing);
        } else if (direction == DOWN) {
            fromSprite.y.animate(0.0, -Stage.getHeight(), duration, easing);
            toSprite.y.animate(Stage.getHeight(), 0.0, duration, easing);
        }
    }

}
