De la doc pour les classe dans UIElement, gestion du clavier dans la classe Button.
This commit is contained in:
@@ -1,22 +1,30 @@
|
||||
package engine.input;
|
||||
|
||||
import engine.Engine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetKey;
|
||||
|
||||
public class Button {
|
||||
|
||||
public String name;
|
||||
private final List<Integer> buttons;
|
||||
private final List<Integer> buttonsGamepad;
|
||||
private final List<Integer> buttonsKeyboard;
|
||||
private final GamepadInput controller;
|
||||
|
||||
public Button(String name, List<Integer> buttons, GamepadInput controller){
|
||||
public Button(String name, List<Integer> buttonsGamepad, List<Integer> buttonsKeyboard, GamepadInput controller){
|
||||
this.name = name;
|
||||
this.buttons = buttons;
|
||||
this.buttonsGamepad = buttonsGamepad;
|
||||
this.buttonsKeyboard = buttonsKeyboard;
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
public boolean isButtonPressed(){
|
||||
for (int i : buttons){
|
||||
for (int i : buttonsGamepad){
|
||||
if (controller.checkPressed(i)) return true;
|
||||
} for (int i : buttonsKeyboard){
|
||||
if (glfwGetKey(Engine.getWindow(), i) == 1) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user