Reputation: 75
I'm a newbie to LibGdx,and i'm having a problem with libgdx in distinguishing between these 2 problems. I'm making a game like canyon defense in miniclip.com. When I touch down and then immediately touch up, a new gun will be added to a list. But when I drag, I just want to move my camera. My problem here is when running on Android phone HTC sensation, I couldn't detect these 2 actions, it always detects that it's a dragging action even though I just touched down and then touched up. On PC, I've already done it, just one click or Drag, everything is done, but on Android, it's so hard, please help me :-) thank in advance :-)
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
// TODO Auto-generated method stub
tempx = screenX;
tempy = screenY;
isDrag = false;
// System.out.println(isDrag);
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
// TODO Auto-generated method stub
vector.x = screenX;
vector.y = screenY;
vector.z = 0;
camera.unproject(vector);
if ((button == Input.Buttons.LEFT) && (isDrag == false)) {
Weapon wp = new Weapon(vector.x, vector.y);
weapon.add(wp);
}
isDrag = false;
// System.out.println(isDrag);
return true;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
// TODO Auto-generated method stub
isDrag = true;
if ((tempy - screenY < 0) && (isOn == true) && (num >= 0)) {
camera.translate(new Vector3(0, 5, 0));
num = num - 5;
}
if ((tempy - screenY > 0) && (isOn == true)
&& (temp.getHeight() >= num)) {
camera.translate(new Vector3(0, -5, 0));
num = num + 5;
}
tempy = screenY;
// System.out.println(isDrag);
return true;
}
Upvotes: 0
Views: 930
Reputation: 3183
Only set isDrag = true;
if you are a certain distance from your tempx
and tempy
.
Upvotes: 1