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)

참고

  • 최대 터치 수는 엔진에 의해 정의
  • 안전한 순회
  • 범위 밖 인덱스는 에러 발생