2016-08-15 14 views
0

파이 게임 프로그램에서 일하고 있으며 화면에 텍스트를 표시하고 싶습니다.파이 게임이 읽기 전용입니다.

screenDi = pygame.display.Info() 
height = screenDi.current_h 
width = screenDi.current_w 
size = width, height 
screen = pygame.display.set_mode(size) 

을 여기에 내 텍스트 함수를 정의 :

여기 내 화면을 정의

def text(text,x,y): 
    font = pygame.font.SysFont('Calibri',50,True,False) 
    text = font.render(text,True,BLACK) 
    screen.blit = (text,[x,y])` 

을하지만, 내가 메인 프로그램에서이 라인을 포함 할 때 :

text('Hello',100,100) 

을 파이썬은 다음과 같은 오류를 반환합니다 :

pygame.Surface object attribute 'blit' is read-only

어떻게하면 해결할 수 있습니까?

답변

1

블릿은() 함수,하지만 당신은 할당하려는 :

screen.blit = (text,[x,y]) 

는 =없이 시도 : 내 부분에

screen.blit(text,[x,y]) 
+0

아 바보 같은 실수를 ... 감사합니다! –