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は以下を公開します:

プロパティ説明
idintユニークなタッチID
posVector2位置
deltaVector2移動量
pressurefloat圧力(サポートされている場合)
startedbool最初のフレームでTrue
endedboolリリース時にTrue

すべてのフィールドは読み取り専用です。


カウント

count = touches.count

または

len(touches)

例:タップ検出

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

注意事項

  • 最大タッチ数はエンジンで定義
  • 安全な反復処理
  • 範囲外のインデックスはエラーが発生