代码:
import pygame, sys
def load ():
image = pygame.image.load ('ShrinSprite.jpg')
return image, image.get_rect ()
class Sprite (pygame.sprite.Sprite):
def __init__ (self):
pygame.sprite.Sprite.__init__ (self)
self.image, self.rect = load ()
sprite = Sprite ()
allsprites = pygame.sprite.RenderClear ((sprite))
Surface = pygame.display.set_mode ((400, 400), 0, 32)
while True:
Surface.fill ((255, 255, 255))
allsprites.draw (0, 0)
for event in pygame.event.get ():
if event.type == QUIT:
pygame.quit ()
sys.exit (0)
if event.type == KEYDOWN:
allsprites.draw (0, -5)
allsprites.clear ()
pygame.display.update ()
该错误指出无法加载图像:
pygame.error: Could not load 'ShrinSprite.jpg'
虽然图片和程序在同一个目录下,但是还是一直出现这个错误