python - pygame " event " object has no attribute "pos"
问题描述
if event.type == pygame.FINGERDOWN:
touch_pos = event.pos
When I run this code ,I get the error 'Event' object has no attribute 'pos' .
If I use pygame.MOUSEBUTTONDOWN it works fine ,with no error.
How to solve this ,do you need to import something?
解决方案
According to this table from https://www.pygame.org/docs/ref/event.html, FINGER~ events have an x
and y
attribute instead of a pos
attribute.
AUDIODEVICEREMOVED which, iscapture
FINGERMOTION touch_id, finger_id, x, y, dx, dy
FINGERDOWN touch_id, finger_id, x, y, dx, dy
FINGERUP touch_id, finger_id, x, y, dx, dy
MOUSEWHEEL which, flipped, x, y
MULTIGESTURE touch_id, x, y, pinched, rotated, num_fingers
TEXTEDITING text, start, length
TEXTINPUT text
WINDOWEVENT event
推荐阅读
- javascript - 错误类型错误:无法设置 null 的属性(变量名)
- postgresql - 有没有办法配置 postgresql 将记录发送到侦听器端口
- python - 如何一次从熊猫的所有列中删除逗号
- asp.net-mvc - 如何在对象结构中设置 Cookie?
- firebase - TypeError:_onRequestWithOpts 不是 Object.httpsProvider._onRequestWithOpts 的函数
- python - 根据python的逻辑引发异常的脚本,但测试用例仍然在机器人框架中通过
- vb.net - 使用 odbc 的 vb.net 连接
- javascript - CSS 在第一次加载时中断,在热重载时得到纠正
- java - 获取惰性 OneToOne 实体会获取同一对象中的所有其他 OneToOne 实体
- python - 无法从 requirements.txt 中找到满足要求“ ”的版本。未找到该软件包的匹配分发