diff --git a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java index e02bc24..4e4b692 100644 --- a/app/src/main/java/jonathan/balljumper/GameSurfaceView.java +++ b/app/src/main/java/jonathan/balljumper/GameSurfaceView.java @@ -11,12 +11,12 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; +import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import jonathan.balljumper.classes.Ball; import jonathan.balljumper.classes.Panel; -import jonathan.balljumper.classes.Sprite; /** * Created by Jonathan on 27/07/2017. @@ -108,7 +108,7 @@ ball.bounce(); } - ball.setY(ball.getY() + ball.getSpeed() * ball.getDirectionY()); + ball.setY(ball.getY() + ball.getSpeed() * ball.getDirection().x); } /** @@ -162,4 +162,20 @@ } } } + + @Override + public boolean onTouchEvent(MotionEvent event) { + super.onTouchEvent(event); + + float x = event.getX(); + float y = event.getY(); + + switch (event.getAction()) { + case MotionEvent.ACTION_MOVE: + ball.setX(x); + break; + } + + return true; + } }