/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.tests;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Bezier;
import com.badlogic.gdx.math.Path;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.Array;

/** @author Xoppa */
public class PathTest extends GdxTest {
	SpriteBatch spriteBatch;
	Sprite obj;
	Array<Path<Vector2>> paths = new Array<Path<Vector2>>();
	int currentPath = 0;
	float t;
	float speed = 0.3f;
	float wait = 0f;

	@Override
	public boolean needsGL20 () {
		return false;
	}
	
	@Override
	public void create () {
		spriteBatch = new SpriteBatch();
		obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
		
		float w = Gdx.graphics.getWidth() - obj.getWidth();
		float h = Gdx.graphics.getHeight() - obj.getHeight();
		
		paths.add(new Bezier<Vector2>(new Vector2(0,0), new Vector2(w, h)));
		paths.add(new Bezier<Vector2>(new Vector2(0,0), new Vector2(0, h), new Vector2(w, h)));
		paths.add(new Bezier<Vector2>(new Vector2(0,0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));
		
		Gdx.input.setInputProcessor(this);
	}
	
	final Vector2 tmpV = new Vector2();
	@Override
	public void render () {
		GL10 gl = Gdx.graphics.getGL10();
		gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		
		if (wait > 0)
			wait -= Gdx.graphics.getDeltaTime();
		else {
			t += speed * Gdx.graphics.getDeltaTime();
			while (t >= 1f) {
				currentPath = (currentPath + 1) % paths.size;
				t -= 1f;
			}
			
			paths.get(currentPath).valueAt(tmpV, t);
			obj.setPosition(tmpV.x, tmpV.y);
		}
		
		spriteBatch.begin();
		obj.draw(spriteBatch);
		spriteBatch.end();
	}
	
	@Override
	public boolean touchUp (int screenX, int screenY, int pointer, int button) {
		t = paths.get(currentPath).approximate(tmpV.set(screenX, Gdx.graphics.getHeight()-screenY));
		paths.get(currentPath).valueAt(tmpV, t);
		obj.setPosition(tmpV.x, tmpV.y);
		wait = 2f;
		return super.touchUp(screenX, screenY, pointer, button);
	}
}

@@ -2657,92 +2657,39 @@
 %0A%09%0A%09
-@Override%0A%09public boolean
+private void
  touch
-Up 
 (int 
-screenX, int screenY, int pointer, int button
+x, int y
 ) %7B%0A
@@ -2738,23 +2738,17 @@
 mpV.set(
-screenX
+x
 , Gdx.gr
@@ -2766,23 +2766,17 @@
 eight()-
-screenY
+y
 ));%0A%09%09pa
@@ -2865,65 +2865,358 @@
  2f;
-%0A%09%09return super.touchUp(screenX, screenY, pointer, button
+%09%09%0A%09%7D%0A%09%0A%09@Override%0A%09public boolean touchUp (int screenX, int screenY, int pointer, int button) %7B%0A%09%09touch(screenX, screenY);%0A%09%09return super.touchUp(screenX, screenY, pointer, button);%0A%09%7D%0A%09%0A%09@Override%0A%09public boolean touchDragged (int screenX, int screenY, int pointer) %7B%0A%09%09touch(screenX, screenY);%0A%09%09return super.touchDragged(screenX, screenY, pointer
 );%0A%09

Add dragging