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
posVector2Current position
start_posVector2Position where the touch began (held for its life)
deltaVector2Movement since last frame
framesintFrames since the touch began (0 on the first frame)
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


Mini samples

Open from Samples & Tutorials inside Pyxen:

  • input.touches — Render a circle at every active touch (iPad/iPhone).