Pygame.time.set_time,我想让它在特定点发生

时间:2016-04-17 02:00:47

标签: python python-2.7 pygame

pygame.time.set_time()

我正在努力使click仅在MOUSEBUTTONDOWN>之后运行0.我尝试将pygame.time.set_time放在if语句中,但这不起作用。任何回复都非常感谢!将计时器开始放在{{1}}事件中时,它只会在单击鼠标时启动,但每次单击它都会重置。

1 个答案:

答案 0 :(得分:0)

def gameLoop():
    ENDTIMER = pygame.USEREVENT+1
    gameExit = False
    gameOver = False
    FPS = 15
    click  = 0
    global click

    timer_on =False

    while not gameExit:


        gameDisplay.fill(white)


        button("CLICK", display_width/2-100,display_height/2-100, 200,200, red, light_red, action=None)



        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                gameExit = True
            if event.type == pygame.MOUSEBUTTONDOWN:
                if not timer_on:
                     timed = pygame.time.set_timer(ENDTIMER, 25000)

                pygame.mixer.Sound.play(boop_sound)
                button("CLICK", display_width/2-100,display_height/2-100, 200,200, red, light_red, action="Click")
                button("CLICK", display_width/2-100,display_height/2-100, 200,200, red, light_red, action=None)


            elif event.type == ENDTIMER:
                gameExit = True



        score(click)


        pygame.display.update()

        clock.tick(FPS)

    game_over()
    pygame.quit()
    quit()