首页 > 解决方案 > 当我在 pygame 中绘制图像时,我看不到我的图像,即使它与我的 python 脚本和脚本所需的其他 python 模块位于同一文件夹中

问题描述

在此处输入图像描述我正在制作一个 python 程序,我想使用模块 pygame 在我的屏幕/表面上绘制图像,但是当我尝试绘制图像时,我看不到它。该图像与我的 python 脚本位于同一文件夹中,因此这不应该是问题。我的语法也是正确的。所以我不知道,如果有人回应我将不胜感激。谢谢!

import pygame,sys

pygame.init()
clock = pygame.time.Clock()
screen=pygame.display.set_mode((800,800))
second_surface=pygame.Surface([100,200])
second_surface.fill((0,0,255))

isaac=pygame.image.load('isaac.png')
while True:
    for event in pygame.event.get():
        if event.type==pygame.QUIT:
            pygame.quit()
            sys.exit()

    screen.fill((255,255,255))
    screen.blit(second_surface,(0,50))
    isaac.blit(isaac,(100,200))
    pygame.display.flip()
    clock.tick(60)

标签: pythonpygamepngsurface

解决方案


Rabbid76 的回答:

isaac.blit(isaac,(100,200))它说它应该在哪里screen.blit(isaac,(100,200))


推荐阅读