我有一些关于在pygame / python中双击(箭头右侧)的麻烦。这是我现在的代码:
timer = 0
exit = True
dt = 0.1
` while exit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit = False
if event.type == pygame.KEYDOWN:
if event.key == seta_direita:
print("Moveu")
if timer == 0: # First click.
timer = 0.1 # Start the timer.
#Click again before 0.3 seconds to double click.
elif timer < 0.3:
print('Dash')
# Increase timer after mouse was pressed the first time.
elif timer != 0:
timer += dt
pygame.time.delay(100)
# Reset after 0.3 seconds.
elif timer >= 0.3:
timer = 0
所以有。
答案 0 :(得分:0)
您当前仅在按下鼠标按钮时才增加计时器,应该在按下按钮时开始计时,并在事件循环时对其进行迭代