pyxen.input.touches
Zugriff auf Touchscreen-Eingabe (Mobilgeräte und Tablets).
touches = pyxen.input.touches
Touch-Unterstützung erkennen
if input.touches.present:
log("Plattform unterstützt Touch")
Iteration
for t in touches:
if t.started:
print(t.id, t.pos)
Indexierung
if len(touches) > 0:
pos = touches[0].pos
player.x = pos.x
Touch-Objekt
Jedes Touch-Objekt bietet:
| Eigenschaft | Typ | Beschreibung |
|---|---|---|
id | int | Eindeutige Touch-ID |
pos | Vector2 | Position |
delta | Vector2 | Bewegung |
pressure | float | Druck (falls unterstützt) |
started | bool | True im ersten Frame |
ended | bool | True beim Loslassen |
Alle Felder sind nur lesbar.
Anzahl
count = touches.count
oder
len(touches)
Beispiel: Tipp-Erkennung
for t in touches:
if t.started:
spawn_explosion(t.pos)
Hinweise
- Maximale Touch-Anzahl durch die Engine definiert
- Sichere Iteration
- Index außerhalb des Bereichs löst Fehler aus