简体   繁体   English

每次尝试运行此项目时,我都会收到“TypeError:'pygame.Surface'对象不可调用”错误

[英]I keep getting the "TypeError: 'pygame.Surface' object is not callable" error every time I try to run this project

import pygame,sys

pygame.init()
screen = pygame.display.set_mode((1366, 720))
clock = pygame.time.Clock()
test_surface = pygame.Surface((100,200))
test_surface.fill(pygame.Color(0, 0, 255))
x_pos = 200


while True:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
         pygame.quit()
         sys.exit()
screen.fill((175,201,70))
x_pos += 1
screen.blit(test_surface(x_pos,500))
pygame.display.update()
clock.tick(60)

This is the code.这是代码。 I cannot find any way to fix this problem.我找不到任何方法来解决这个问题。 Any help on this would be appreciated.对此的任何帮助将不胜感激。

import pygame,sys
if __name__ == "__main__":
    pygame.init()
    screen = pygame.display.set_mode((1366, 720))
    clock = pygame.time.Clock()
    test_surface = pygame.Surface((100,200))
    test_surface.fill(pygame.Color(0, 0, 255))
    x_pos = 200
    screen.fill((175,201,70))
    x_pos += 1
    screen.blit(test_surface, (x_pos,500))
    pygame.display.update()
    clock.tick(60)

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

you can use this code你可以使用这个代码
error was in screen.blit, first argument is surface, and second argument is coords错误在 screen.blit 中,第一个参数是表面,第二个参数是坐标

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

相关问题 我的程序无法运行,而不是使用黑色背景,而是尝试将图像用作背景错误:pygame.surface'对象不可调用 - My program will not run, when instead of using a black background i try to use a image as background ERROR: pygame.surface' object is not callable 我不断收到“TypeError: 'pygame.Surface' object is not subscriptable”,有人可以帮我吗? - I keep getting the "TypeError: 'pygame.Surface' object is not subscriptable", can someone help me? Python 错误(类型错误:'pygame.Surface' object 不可调用) - Python Error (TypeError: 'pygame.Surface' object is not callable) TypeError:pygame.Surface对象不可调用 - TypeError: pygame.Surface object not callable TypeError:“ pygame.Surface”对象不可调用 - TypeError: 'pygame.Surface' object is not callable 当我使用方法时,出现TypeError:'pygame.Surface'对象不可调用, - when I use a method,I get a TypeError: 'pygame.Surface' object is not callable, 'pygame.Surface'对象不可调用错误 - 'pygame.Surface ' object is not callable error 错误:'pygame.Surface' object 不可调用 - Error: 'pygame.Surface' object is not callable TypeError:“ pygame.Surface”对象不可调用[Pygame模块] - TypeError: 'pygame.Surface' object is not callable [Pygame module] Pygame。 TypeError:“ pygame.Surface”对象不可调用 - Pygame. TypeError: 'pygame.Surface' object is not callable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM