2013-04-23 83 views
1
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 /壓痕錯誤,我是新來的蟒蛇,想知道什麼是錯的?

回答

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

Pos位於一個非常正確的位置。

1

  pos = pygame.mouse.get_pos() 

有一個額外的空間。爲了清楚地看到,刪除評論有幫助。

  pos = pygame.mouse.get_pos() 
     self.circ.x=pos[0] 
     self.circ.y=pos[1] 
相關問題