问题描述
if event.type == pygame.FINGERDOWN:
touch_pos = event.pos
如果我使用 pygame.MOUSEBUTTONDOWN 它工作正常,没有错误。
如何解决这个问题,需要导入吗?
解决方法
根据 here 中的这张表,FINGER~ 事件具有 x
和 y
属性而不是 pos
属性。
AUDIODEVICEREMOVED which,iscapture
FINGERMOTION touch_id,finger_id,x,y,dx,dy
FINGERDOWN touch_id,dy
FINGERUP touch_id,dy
MOUSEWHEEL which,flipped,y
MULTIGESTURE touch_id,pinched,rotated,num_fingers
TEXTEDITING text,start,length
TEXTINPUT text
WINDOWEVENT event