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