2016-03-01 25 views
0
def texts(score): 
    font=pygame.font.Font(None,30) 
    scoretext=font.render("Score:"+str(score), 1,(255,255,255)) 
    screen.blit(scoretext, (500, 457)) 

這個第二個參數(1)在font.render是什麼意思?顯示文字參數說明

class safeguardClass(pygame.sprite.Sprite): 
    def __init__(self,image_file, location = [0,0]): 
     pygame.sprite.Sprite.__init__(self) #call Sprite initializer 
     self.image = pygame.image.load(image_file) 
     self.rect = self.image.get_rect() 
     self.rect.left, self.rect.top = location 

此外,請親引導我在上面的子類中是什麼self

+0

無論何時您不確定參數以及現有的庫函數的作用,從相同的文檔開始是非常好的開始。如果您選擇不查看文檔,那麼需要很長時間才能瞭解「耶穌是代碼的全部內容」?它不會比在鍵盤上隨機打字更有意義。 Pygame渲染函數的文檔在這裏 - http://www.pygame.org/docs/ref/font.html#pygame.font.Font.render – malhar

回答

0

如果您查找的pygame.font.Font.renderdocumentation它表明:

render(text, antialias, color, background=None) -> Surface 

這將創建一個新的表面與呈現在指定的文本它。 Pygame沒有辦法直接在現有的Surface上繪製文本:相反,您必須使用Font.render()創建文本的圖像(Surface),然後將該圖像粘貼到另一個Surface上。

(...)

antialias參數是一個布爾如果真人物角色將有平滑的邊緣

此外self是對您正在構建的對象__init__ function的引用。