Coverage Summary for Class: ControlScreenInputHandler (com.mozarellabytes.kroy.Utilities)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
ControlScreenInputHandler | 0% (0/ 1) | 0% (0/ 9) | 0% (0/ 18) |
1 package com.mozarellabytes.kroy.Utilities;
2
3 import com.badlogic.gdx.Input;
4 import com.badlogic.gdx.InputProcessor;
5 import com.badlogic.gdx.math.Vector2;
6 import com.badlogic.gdx.math.Vector3;
7 import com.mozarellabytes.kroy.Screens.ControlsScreen;
8
9 /**
10 * This class controls the input for the Control screen
11 * */
12 public class ControlScreenInputHandler implements InputProcessor {
13
14 private final ControlsScreen controlsScreen;
15
16 /**
17 * Constructs the control screen input handler
18 *
19 * @param controlsScreen the control screen that this input handler controls
20 */
21 public ControlScreenInputHandler(ControlsScreen controlsScreen) {
22
23 this.controlsScreen = controlsScreen;
24 }
25
26 /** Called when a key was pressed
27 *
28 * Changes the screen to and from the controls screen when
29 * 'C' is pressed
30 *
31 * @param keycode one of the constants in {@link Input.Keys}
32 * @return whether the input was processed */
33 @Override
34 public boolean keyDown(int keycode) {
35 switch (keycode) {
36 case Input.Keys.ESCAPE:
37 case Input.Keys.C:
38 controlsScreen.changeScreen();
39 break;
40 }
41 return true;
42 }
43
44
45 @Override
46 public boolean keyUp(int keycode) {
47 if (keycode == Input.Keys.A) {
48 SoundFX.sfx_truck_attack.stop();
49 }
50 return false;
51 }
52
53 @Override
54 public boolean keyTyped(char character) {
55 return false;
56 }
57
58 /** Called when the screen was touched or a mouse button was pressed.
59 *
60 * Goes back to the screen where the menu screen was called from when the
61 * exit button was pressed
62 *
63 * @param screenX The x coordinate, origin is in the upper left corner
64 * @param screenY The y coordinate, origin is in the upper left corner
65 * @param pointer the pointer for the event.
66 * @param button the button
67 * @return whether the input was processed */
68 @Override
69 public boolean touchDown(int screenX, int screenY, int pointer, int button) {
70 Vector2 clickCoordinates = new Vector2(screenX, screenY);
71 Vector3 position = controlsScreen.camera.unproject(new Vector3(clickCoordinates.x, clickCoordinates.y, 0));
72 if(controlsScreen.getExitButton().contains(position.x, position.y)){
73 controlsScreen.changeScreen();
74 }
75 return false;
76 }
77
78 @Override
79 public boolean touchUp(int screenX, int screenY, int pointer, int button) {
80 return false;
81 }
82
83 @Override
84 public boolean touchDragged(int screenX, int screenY, int pointer) {
85 return false;
86 }
87
88 @Override
89 public boolean mouseMoved(int screenX, int screenY) {
90 return false;
91 }
92
93 @Override
94 public boolean scrolled(int amount) {
95 return false;
96 }
97
98 }