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()