1
손가락을 화면에서 들었을 때를 감지하는 방법을 알아 내려고합니다. 내가 생각하지만터치 다운 후 터치 업을 감지하는 방법
for(int i = 0; i < len; i++) {
TouchEvent event = touchEvents.get(i);
if(event.type == TouchEvent.TOUCH_DOWN) {
while (event.type != TouchEvent.TOUCH_UP){
if((event.y > 160) && ((world.batMan.getY() + world.batMan.getLength()) < 319)) {
world.bat.moveSouth();
}
if((event.y < 160) && (world.batMan.getY() > 0)) {
world.bat.moveNorth();
}
event = touchEvents.get(i);
}
}
}
그것을 해결 : Essentialy 나는 한 번 손가락은 같은 손가락이 지금까지까지 손가락을 이동하면 감지하지 못하는 무슨 최대가 될 때까지 아래로 내 프로그램이 작업을 수행 할 이제는 필요 이상으로 복잡해졌습니다!
을 위해 (내가 < 렌, I = 0을 int로 내가 ++) { TouchEvent event = touchEvents.get(i);
if (event.type == TouchEvent.TOUCH_UP)
{
System.out.println("WOOT");
touchNorth = false;
touchSouth = false;
}
else {
if((event.y > 160) && ((world.bat.getY() + world.bat.getLength()) < 319)
| (touchSouth == true)) {
touchSouth = true;
}
if((event.y < 160) && (world.bat.getY() > 0) | (touchNorth == true)) {
touchNorth = true;
}
}
}
if((touchSouth == true) && ((world.bat.getY() + world.bat.getLength()) < 319)) {
world.bat.moveSouth();
touchSouth = true;
}
if(touchNorth == true && (world.bat.getY() > 0)) {
world.bat.moveNorth();
touchNorth = true;
}