api:documentation:spiele:gamepad
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
— | api:documentation:spiele:gamepad [2024/08/31 10:03] (aktuell) – angelegt - Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Gamepad ====== | ||
+ | <WRAP center round info 100%> | ||
+ | Der Status des Gamepads kann in den Unterklassen der Klasse '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Darüber hinaus kann der Gamepad-Status auch über die gleichnamigen statischen Methoden der Klasse '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Aus Sicherheitsgründen ordnen die Browser ein angeschlossenes Gamepad einer Webseite erst dann zu, wenn die Webseite den Fokus hat und der Benutzer erstmals eine Taste/einen Steuerknüppel betätigt hat. Erst dann gibt '' | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | <div class=" | ||
+ | |||
+ | <script type=" | ||
+ | SystemTools.setSpeed(-1); | ||
+ | |||
+ | new GamepadConnectedText(); | ||
+ | |||
+ | new GamepadAxisCircle(0, | ||
+ | new GamepadAxisCircle(2, | ||
+ | |||
+ | for(int i = 0; i < 20; i++) { | ||
+ | | ||
+ | new GamepadButtonRect(i, | ||
+ | Text t = new Text(x + 10, 450, 24, i); | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | class GamepadAxisCircle extends Circle { | ||
+ | int axisIndexX; | ||
+ | int axisIndexY; | ||
+ | | ||
+ | | ||
+ | | ||
+ | super(mx, my, 40); | ||
+ | setFillColor(color); | ||
+ | this.axisIndexX = axisIndexX; | ||
+ | this.axisIndexY = axisIndexY; | ||
+ | this.mx = mx; | ||
+ | this.my = my; | ||
+ | } | ||
+ | |||
+ | void act() { | ||
+ | | ||
+ | moveTo(mx + getGamepadAxisValue(0, | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | class GamepadButtonRect extends Rectangle { | ||
+ | |||
+ | int buttonIndex; | ||
+ | int color; | ||
+ | |||
+ | | ||
+ | super(x, y, width, width); | ||
+ | setBorderColor(color); | ||
+ | setBorderWidth(3); | ||
+ | this.color = color; | ||
+ | this.buttonIndex = buttonIndex; | ||
+ | } | ||
+ | | ||
+ | | ||
+ | if(isGamepadButtonDown(0, | ||
+ | | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | class GamepadConnectedText extends Text { | ||
+ | | ||
+ | super(10, 10, 32, "" | ||
+ | setFillColor(Color.white); | ||
+ | } | ||
+ | | ||
+ | if(isGamepadConnected(0)) { | ||
+ | | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ |