0
我想在pygame中製作一個按鈕。它應該在每次點擊時顯示三個新圖像。一切正常,除非這些圖像只在點擊按鈕時出現。顯示圖像的代碼如下,它是一個更大的while循環的一部分,現在持續無限。我怎樣才能讓圖像保持到再次按下按鈕並出現新圖像?任何幫助表示讚賞,在此先感謝。如何使pygame中的按鈕顯示和更新圖像?
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
element = -1
if 1120 > mouse [0] > 865 and 330 > mouse [1] > 250:
screen.blit (dice_button_light, (870, 250))
if click [0] == 1:
dice_choices = Dice.dice_choice()
print(dice_choices)
element = -1
for i in dice_choices:
element += 1
x = 750
if element == 1:
x += 100
if element == 2:
x += 200
if i == 1:
screen.blit (dice1,(x,100))
elif i == 2:
screen.blit (dice2,(x,100))
elif i == 3:
screen.blit (dice3,(x,100))
elif i == 4:
screen.blit (dice4,(x,100))
elif i == 5:
screen.blit (dice5,(x,100))
elif i == 6:
screen.blit (dice6,(x,100))
else:
screen.blit (dice_button, (870, 250))