Example #1
0
 @Override
 protected void processTouch(TouchEvent touch) {
   super.processTouch(touch);
   if (getMessage() != null) {
     return;
   }
   if (touch.type == TouchEvent.TOUCH_DOWN && touch.pointer == 0) {
     startX = touch.x;
     startY = lastY = touch.y;
   }
   if (touch.type == TouchEvent.TOUCH_DRAGGED && touch.pointer == 0) {
     if (touch.x > (1920 - NavigationBar.SIZE)) {
       return;
     }
     yPosition += lastY - touch.y;
     if (yPosition < 0) {
       yPosition = 0;
     }
     if (yPosition > maxY) {
       yPosition = maxY;
     }
     lastY = touch.y;
   }
   if (touch.type == TouchEvent.TOUCH_UP && touch.pointer == 0) {
     if (Math.abs(startX - touch.x) < 20 && Math.abs(startY - touch.y) < 20) {
       if (done.isTouched(touch.x, touch.y)) {
         assignState((Alite) game);
         ((Alite) game).getNavigationBar().setActive(true);
         ((Alite) game).getNavigationBar().setActiveIndex(2);
         newScreen = new StatusScreen(game);
         SoundManager.play(Assets.click);
       } else {
         for (int i = 0; i < 256; i++) {
           Button b = values[i];
           b.setSelected(false);
           if (b.isTouched(touch.x, touch.y)) {
             b.setSelected(true);
             if ((i % 16) < 8) {
               newScreen = new HexNumberPadScreen(this, game, 975, 180, i);
             } else {
               newScreen = new HexNumberPadScreen(this, game, 60, 180, i);
             }
             SoundManager.play(Assets.click);
           }
         }
       }
     }
   }
   if (touch.type == TouchEvent.TOUCH_SWEEP) {
     deltaY = touch.y2;
   }
 }
 @Override
 protected void processTouch(TouchEvent touch) {
   if (touch.type == TouchEvent.TOUCH_UP) {
     if (difficultyLevel.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       Settings.difficultyLevel++;
       if (Settings.difficultyLevel > 5) {
         Settings.difficultyLevel = 0;
       }
       difficultyLevel.setText("Difficulty Level: " + getDifficultyString());
       Settings.save(game.getFileIO());
     } else if (autoId.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       Settings.autoId = !Settings.autoId;
       autoId.setText("Auto Id: " + (Settings.autoId ? "On" : "Off"));
       Settings.save(game.getFileIO());
     } else if (keyboardLayout.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       if ("QWERTY".equals(Settings.keyboardLayout)) {
         Settings.keyboardLayout = "QWERTZ";
       } else {
         Settings.keyboardLayout = "QWERTY";
       }
       keyboardLayout.setText("Keyboard: " + Settings.keyboardLayout);
       Settings.save(game.getFileIO());
     } else if (dockingSpeed.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       Settings.dockingComputerSpeed++;
       if (Settings.dockingComputerSpeed > 2) {
         Settings.dockingComputerSpeed = 0;
       }
       dockingSpeed.setText(
           "Docking Computer: "
               + (Settings.dockingComputerSpeed == 0
                   ? "Slow"
                   : (Settings.dockingComputerSpeed == 1 ? "Medium" : "Fast")));
       Settings.save(game.getFileIO());
     } else if (laserAutoFire.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       Settings.laserButtonAutofire = !Settings.laserButtonAutofire;
       laserAutoFire.setText(
           "Laser: " + (Settings.laserButtonAutofire ? "Auto Fire" : "Single Shot"));
       Settings.save(game.getFileIO());
     } else if (back.isTouched(touch.x, touch.y)) {
       SoundManager.play(Assets.click);
       newScreen = new OptionsScreen(game);
     }
   }
 }