bif="bg.jpeg"
mif="ball.png"
import pygame
import sys
from pygame.locals import *
pygame.init()
screen_size=(640, 360)
screen=pygame.display.set_mode(screen_size, 0, 32)
background=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(bif).convert_alpha()
while (True):
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.blit(background, (0,0))
x,y = pygame.mouse.get_pos()
x -=mouse_c.get_width()/2
y -=mouse_c.get_height()/2
screeb.blit(mouse_c, (x,y))
pygame.display.update()
回溯(最近通话最后一个):pygame的不加载图片(蟒蛇)(2.7.5)
文件 “C:\用户\奥菲克\桌面\游戏\ try.py”线12,在
背景= pygame.image.load(BIF).convert()
pygame.error:无法打开C:\用户\地平线\桌面\游戏\ bg.jpeg
确保您的图像位于相同的目录中。确保你的路径是正确的。 – ecline6
它是在相同的目录.. – user2410243
你确定吗?请确保它的名称,并确保它的名称正确。你可以尝试使用绝对路径。 bif =“C:\\ Users \\ Ofek \\ Desktop \\ game \\ bg.jpeg” – ecline6