【发布时间】:2014-03-18 09:50:09
【问题描述】:
我是 LibGdx 的新手,我在区分这两个问题时遇到了 libgdx 的问题。 我正在 miniclip.com 中制作类似峡谷防御的游戏。 当我触地然后立即触地时,新枪将被添加到列表中。 但是当我拖动时,我只想移动我的相机。 我这里的问题是在Android手机HTC感觉上运行时,我无法检测到这两个动作,即使我只是先触地然后再触,它总是检测到这是一个拖动动作。 在PC上,我已经做到了,只需单击或拖动,一切都完成了,但是在Android上,这太难了,请帮助我:-)提前谢谢:-)
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;
}
【问题讨论】: