pyxen.input.touches

Access touchscreen input (mobile & tablets).

touches = pyxen.input.touches

Detect Touch Support

if input.touches.present:
    log("platform supports touches")

Iteration

for t in touches:
    if t.started:
        print(t.id, t.pos)

Indexing

if len(touches) > 0:
    pos = touches[0].pos
    player.x = pos.x

Touch Object

Each Touch exposes:

PropertyTypeDescription
idintUnique touch ID
posVector2Position
deltaVector2Movement
pressurefloatPressure (if supported)
startedboolTrue on first frame
endedboolTrue on release

All fields are read-only.


Count

count = touches.count

or

len(touches)

Example: Tap Detection

for t in touches:
    if t.started:
        spawn_explosion(t.pos)

Notes

  • Maximum touches defined by engine
  • Safe iteration
  • Index out of range raises error