I have eight shapes, and I put a loop to detect the mouse clicked, it failed. When I click the mouse, the program can not detected my mouse. As the program skipped the if statement.
Here’s some example code:
cards = [card_0, card_1,card_2, card_3, card_4,card_5,card_6,card_7] myMouse = event.Mouse() clicked=False line_0.draw() line_1.draw() line_2.draw() line_3.draw() line_4.draw() line_5.draw() line_6.draw() line_7.draw() card_0.draw() card_1.draw() card_2.draw() card_3.draw() card_4.draw() card_5.draw() card_6.draw() card_7.draw() win.flip() while not clicked: # check the list of shapes for n,card in enumerate(cards): if myMouse.isPressedIn(card): clicked = True response = n break # exit this loop else: # this runs once at the completion of the for loop time.sleep(0.01) response=n*100 print response myMouse.clickReset()
Any help would be much appreciated!