我试图在pygame中输入鼠标按钮,但它不起作用。我试过了
if pygame.mouse.get_pressed() == True:
"do something"
,
if pygame.mouse.get_pressed() == (1,0,0):
"do something"
,
if pygame.mouse.get_pressed()[0]:
"do something"
...
我认为文档中的所有内容都是如此,但if pygame.mouse.get_pressed() == (1,0,0):
之前始终有效。
(if mouse_pos == (PlayCoordsx, PlayCoordsy) and pygame.mouse.get_pressed() == (1, 0, 0):
)
有人能告诉我我做错了吗?
答案 0 :(得分:2)
首先,不建议使用mouse.get_pressed()。而是使用event.get()并检查事件是什么。例如
while ... # This is your main loop
# get all recent events
events = pygame.event.get()
# proceed events
for event in events:
# handle MOUSEBUTTONUP, ie. click release
if event.type == pygame.MOUSEBUTTONUP:
pos = pygame.mouse.get_pos()
#Do your stuff