0

I'm struggling to find a solution to this. I've got a quiz game that blits button objects to the screen depending on the screen that has been told to display. When a button is clicked, a different set of button objects may be displayed, similar to a menu system. (This is very simplified)

The previously displayed buttons are still clickable through the currently displayed ones, is there a way to somewhat disable the previously blitted buttons? This is the click recognition using the button's rect collisions.

while True:
    
    mousePos = pygame.mouse.get_pos()
    
    #---- Events ----#

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

        elif event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:
                for button in objects:
                    if button.rect.collidepoint(mousePos):
                        button.onClick()
LH123
  • 1
  • 1
    Remove the "old" buttons from `objects`. – Rabbid76 Apr 19 '21 at 18:24
  • You could add an `enabled`-Attribut to you Button-Class. Once you want them to be disabled, you set the attribut to 'false'. Then you only need to check in your loop, if `enabled==true`. – Twistios_Player Jul 11 '21 at 19:50

0 Answers0