Pygame加载图像显示为纯黑色的问题求助
Pygame加载图像显示为纯黑色的问题求助
我最近用Pygame写小项目时遇到个特别头疼的问题——明明按逻辑加载了图像,结果运行起来图像位置只显示一个纯黑色的方块,完全看不到原本的图像内容!我目前使用的是Python 3.12.8版本,下面是我写的代码:
import pygame pygame.init() def imageload(imagepath): return pygame.image.load(imagepath) screen = pygame.display.set_mode((300, 200), 0, 32) pygame.display.set_caption('Python Clicker') background_colour = (255,255,255) cookieimage = Surface.convert(imageload('images/python.bmp')) running = True while running: screen.fill(background_colour) screen.blit(pygame.Surface((64,64), 0, cookieimage), (150, 100), None, 0) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit()
实际运行后的显示效果如下:

有没有大佬能帮我排查下问题出在哪儿呀?实在搞不明白为啥会这样😭
备注:内容来源于stack exchange,提问作者thesquaredude
相关产品推荐
相关产品推荐

