繁体   English   中英

Pygame 'pygame.Surface' object 不可调用

[英]Pygame 'pygame.Surface' object is not callable

我正在尝试制作游戏 pygame 库。但是出现错误。 我看了一些论坛,但我什么都做不了。 如果可以帮助我,我会很高兴。

File C:/Users/User/PycharmProjects/zaxd/main.py", line 34, in <module>
    screen.blit(playerImg(playerX, playerY))
TypeError: pygame.Surface object is not callable

''' 导入 pygame

    # Initialize library
    pygame.init()
    # Variables
    running = True
    pd = pygame.display
    pi = pygame.image
    # Create Screen
    screen = pygame.display.set_mode((800, 600))
    # Caption and Icon
    pd.set_caption("Space Invaders")
    icon = pi.load('ufo.png')
    pd.set_icon(icon)
    # Player
    playerImg = pi.load('plane.png')
    playerX = 370
    playerY = 480


    def player():
        screen.blit(playerImg(playerX, playerY))


    # Game Loop
    while running:

        screen.fill((0, 0, 0))
        for event in pygame.event.get():
            if event == pygame.QUIT:
                running = False
        # Change BG Color (Black)
        player()
        pd.update()
    '''

您在 playerImg 和 (x,y) 坐标之间缺少逗号

screen.blit(playerImg,(playerX, playerY))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM