Mac OS 上的 Pygame 图像 FilenotFoundError

问题描述 投票:0回答:1

所以我使用 pycharm 在 Pygame 中制作游戏,每次我尝试加载图像时,它都会显示“FileNotFoundError:在工作目录 '/Users/lendimaxhuni/PycharmProjects/pythonProject' 中找不到文件 'Cloud.png'”,我已经尝试过将 safari 上的下载位置(我在 MacOS 上)重定向到 pythonProject 文件夹,但它仍然不起作用,此时我迫切需要帮助。 注意:我使用的是 MAC 操作系统,有关更多信息,我正在使用 Pycharm。这是我的代码:

import pygame
from sys import exit

pygame.init()

screen = pygame.display.set_mode((800,400))
pygame.display.set_caption('Speed/Runner')
clock = pygame.time.Clock()

surface = pygame.image.load("Cloud.png").convert()

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

    screen.blit(surface,(200,100))

    pygame.display.update()
clock.tick(60)
python pygame
1个回答
0
投票

注意:我在 MAC 操作系统上,有关其他信息,我正在使用 Pycharm。(如果您想要更多信息,只需评论它,因为我定期检查,我会看到它)。

© www.soinside.com 2019 - 2024. All rights reserved.