0
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 新手,想知道出了什么问题?

4

3 回答 3

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]
于 2013-04-23T10:56:30.530 回答
1

线

         pos = pygame.mouse.get_pos()

有一个额外的空间。为了清楚地看到这一点,删除评论会有所帮助。

         pos = pygame.mouse.get_pos()
        self.circ.x=pos[0]
        self.circ.y=pos[1]
于 2013-04-23T12:23:17.023 回答
1

Pos 的位置太靠右了。

于 2013-04-23T11:06:29.337 回答