[英]Python: How do I detect when a mouse clicks on a image?
最近,我一直在使用pygame,并且试图检测鼠标何时单击图像。 这是我的一些代码,但是我一直收到错误消息:“ pygame.Rect”对象没有属性“ collide_point”。 如何修复代码? 这是我使用的代码:
if event.type == pygame.MOUSEBUTTONDOWN:
(x, y) = event.pos
if Button_Start.get_rect().collide_point(x, y):
print()
该属性是collidepoint()
。 没有下划线。
if event.type == pygame.MOUSEBUTTONDOWN:
(x, y) = event.pos
if Button_Start.get_rect().collidepoint(x, y):
print()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.