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:
| Property | Type | Description |
|---|---|---|
id | int | Unique touch ID |
pos | Vector2 | Position |
delta | Vector2 | Movement |
pressure | float | Pressure (if supported) |
started | bool | True on first frame |
ended | bool | True 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