def update(self):
# Get the current mouse position. This returns the position
# as a list of two numbers
pos = pygame.mouse.get_pos()
# Fetch the x and y out of the list,
# just like we'd fetch letters out of a string.
# Set the player object to the mouse location
self.circ.x=pos[0]
self.circ.y=pos[1]
初始化Pygame
在self.circ.x = pos [0]的地方似乎有一个unident / indentation错误,我是python的新手并且想知道出了什么问题?
答案 0 :(得分:2)
在pos变量删除之前你有一个空格。
def update(self):
# Get the current mouse position. This returns the position
# as a list of two numbers
pos = pygame.mouse.get_pos()
# Fetch the x and y out of the list,
# just like we'd fetch letters out of a string.
# Set the player object to the mouse location
self.circ.x=pos[0]
self.circ.y=pos[1]
答案 1 :(得分:1)
Pos位于右侧。
答案 2 :(得分:1)
该行
pos = pygame.mouse.get_pos()
有一个额外的空间。要清楚地看到这一点,删除评论会有所帮助。
pos = pygame.mouse.get_pos()
self.circ.x=pos[0]
self.circ.y=pos[1]