Как я могу показать текст за изображением?Python

Программы на Python
Anonymous
Как я могу показать текст за изображением?

Сообщение Anonymous »

Как это исправить?
Я не вижу текст над фоновым изображением. Как мне создать поверхность, которая появляется поверх фонового изображения?Я пытаюсь создать кнопки для своей игры, поэтому мне нужно будет размещать все больше и больше текста на главной странице, но ничего не помогает, чтобы текст появлялся над изображением, и он всплывает без текста несмотря на наличие в коде функции «переворот» и функции обновления.
#Err0r AttributeError: type object 'pygame.surface.Surface' has no attribute 'text_surface'

pygame.init()
screen = pygame.display.set_mode((1000,800))
clock = pygame.time.Clock()
pygame.display.set_caption('The Chieftain')
test_surface = pygame.image.load('ChieftainGameFolder/Pictures/Game Background/background.PNG').convert_alpha()
tw = test_surface.get_width()
th = test_surface.get_height()
#place elements here, what makes the game run
test_surface2 = pygame.transform.scale(test_surface, (tw * 1.11482720178 ,th * 1.12201963534))

text_font = pygame.font.SysFont("Arial",30)
def draw_text(text, font, text_col, x, y):
img = font.render(text,True,text_col,)
screen.blit(img, (x,y))
TEXT_COL = (255,255,255)

#gameloop
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()

draw_text("Chieftain", text_font, (0,0,0), 500, 400)

screen.blit(test_surface2,(0,0))
screen.blit(pygame.surface.Surface.text_surface, (500,400))
pygame.display.flip()
pygame.display.update()
clock.tick(60)



Подробнее здесь: https://stackoverflow.com/questions/783 ... -the-image

Вернуться в «Python»