如何在Pygame中使函数显示纹理?

问题描述

我们想制作一种菜单,其中包含一个游戏教程,该教程将在开始时出现在舞台上方,并且当玩家按下帮助按钮时,就像暂停菜单一样,但是我们无法使纹理出现通过功能,纹理根本不会出现。

这是我设法和朋友一起获取代码

所有的东西都在我们trsting和它们出现时正确地声明了,但是当我们将其放入一个函数(JanelaFase1)并试图将其称为纹理时,它并没有出现。

def main_menu():

    while True:
        screen.fill((0,0))
        draw_text('main menu',font,(255,255,255),screen,20,20)
        mx,my = pygame.mouse.get_pos()

        button_1 = pygame.Rect(400,50,800,200)
        button_2 = pygame.Rect(450,500,720,180)

        if button_1.collidepoint((mx,my)):
            if click:
                game()
                JanelaFase1()
                pg.display.flip()
        if button_2.collidepoint((mx,my)):
            if click:
                options()


def game():
    running = True
    while running:
        screen.fill((0,0))
        draw_text('game',20)
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    running = False

        screen.blit(BACKGROUND_FASE,(0,0))
        pygame.display.update()
        mainClock.tick(60)


def JanelaFase1():
    running = True
    while running:
        screen.blit(texto,(300,100))
        pygame.display.update()
        mainClock.tick(60)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)