1
當試圖做塊存儲在一個元組我得到以下錯誤的圖像存儲在一個元組pygame.Surface:阻擊器使用pygame的
Traceback (most recent call last):
File "/home/lyut/Projects/FruitMachine/test.py", line 40, in <module>
if __name__ == '__main__': main()
File "/home/lyut/Projects/FruitMachine/test.py", line 34, in main
draw_initial_gems()
File "/home/lyut/Projects/FruitMachine/test.py", line 11, in draw_initial_gems
pygame.Surface.blit(gems[0], (212, 100))
TypeError: argument 1 must be pygame.Surface, not tuple
我環顧四周,類似的問題,並沒有發現任何與此問題完全一致。
這裏是我用來重現錯誤的源代碼:
import pygame
gems = [
pygame.image.load("graphics/Gems/1.png"),
pygame.image.load("graphics/Gems/2.png"),
pygame.image.load("graphics/Gems/3.png"),
]
def draw_initial_gems():
pygame.Surface.blit(gems[0], (212, 100))
pygame.Surface.blit(gems[1], (340, 100))
pygame.Surface.blit(gems[2], (468, 100))
def main():
pygame.init()
clock = pygame.time.Clock()
print type(gems[1]) # returns: <type 'pygame.Surface'>
size = [800, 600]
screen = pygame.display.set_mode(size)
pygame.display.set_caption("test")
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
screen.fill((255, 255, 255))
draw_initial_gems()
pygame.time.tick(30)
pygame.quit()
if __name__ == '__main__': main()
所以我的問題是:如何的blit存儲在一個元組的圖像?