Validate pointer position
This commit is contained in:
parent
97f3dfc265
commit
3fb92acf46
@ -35,6 +35,7 @@ public class Pointer {
|
||||
public void update(int horizontal, int vertical) {
|
||||
x += horizontal * screenWidth / 50f;
|
||||
y += vertical * screenHeight / 50f;
|
||||
validatePosition();
|
||||
}
|
||||
|
||||
public void draw(ShapeRenderer renderer) {
|
||||
@ -54,5 +55,14 @@ public class Pointer {
|
||||
|
||||
x += ax * screenWidth / 500f;
|
||||
y += ay * screenHeight / 500f;
|
||||
validatePosition();
|
||||
}
|
||||
|
||||
private void validatePosition() {
|
||||
if (x < 0) x = 0;
|
||||
else if (x > screenWidth) x = screenWidth;
|
||||
|
||||
if (y < 0) y = 0;
|
||||
else if (y > screenHeight) y = screenHeight;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user