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'
雖然圖像是在同一個目錄下的程序,這個錯誤仍然保持出現
也許嘗試其他文件格式? – Cemre