pyxen.input.touches
タッチスクリーン入力(モバイル&タブレット)にアクセスします。
touches = pyxen.input.touches
タッチサポートの検出
if input.touches.present:
log("platform supports touches")
反復処理
for t in touches:
if t.started:
print(t.id, t.pos)
インデックスアクセス
if len(touches) > 0:
pos = touches[0].pos
player.x = pos.x
Touchオブジェクト
各Touchは以下を公開します:
| プロパティ | 型 | 説明 |
|---|---|---|
id | int | ユニークなタッチID |
pos | Vector2 | 位置 |
delta | Vector2 | 移動量 |
pressure | float | 圧力(サポートされている場合) |
started | bool | 最初のフレームでTrue |
ended | bool | リリース時にTrue |
すべてのフィールドは読み取り専用です。
カウント
count = touches.count
または
len(touches)
例:タップ検出
for t in touches:
if t.started:
spawn_explosion(t.pos)
注意事項
- 最大タッチ数はエンジンで定義
- 安全な反復処理
- 範囲外のインデックスはエラーが発生