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 | Current position |
start_pos | Vector2 | Position where the touch began (held for its life) |
delta | Vector2 | Movement since last frame |
frames | int | Frames since the touch began (0 on the first frame) |
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
Mini samples
Open from Samples & Tutorials inside Pyxen:
- input.touches — Render a circle at every active touch (iPad/iPhone).