所以我正在尝试为pygame中的游戏制作菜单,直到我开始尝试使选项或在选择选项时出现高分屏幕时,一切都进行得很好。
即使我试图在当前表面上绘制/变色,主菜单也仍然停留在屏幕上(我知道您无法擦除对象或必须在其上绘制一些东西)。
只是想知道是否有人可以指出我在做什么,以及如何在选择菜单选项时创建新屏幕以切换到该屏幕。
这是我尝试通过以下方法在当前表面上涂抹的代码:
def highscores(title, title_rect): # this is called when the high score button is clicked by the user
menu = False
screen = pygame.display.set_mode((800, 600))
screen.fill(pygame.Color("black"))
background = pygame.image.load("assets/newbackground.jpg")
screen.blit(background, (0,0)) # trying to blit over the current surface with an image
screen.blit(title, (800/2 - (title_rect[2]/2), 80)) # trying to blit a title onto the new screen
pygame.display.flip()