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:

EigenschaftTypBeschreibung
idintEindeutige Touch-ID
posVector2Position
deltaVector2Bewegung
pressurefloatDruck (falls unterstützt)
startedboolTrue im ersten Frame
endedboolTrue 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