I was looking through a pygame tutorial and encountered the following part of a script:
fontObj = pygame.font.Font('freesansbold.ttf', 32)
textSurfaceObj = fontObj.render('hellow world', True, Green, Blue)
textRectObj = textSurfaceObj.get_rect()
textRectObj.center = (200,150)
The last line set the center of the rect at (200.150) I looked through the pygame documentation and there is no center attribute in the Rect class. But the script works... why ?
答案 0 :(得分:2)
根据docs on rect:
Rect对象有几个虚拟属性,可用于移动和对齐Rect:
的x,y
顶部,左侧,底部,右侧
topleft,bottomleft,topright,bottomright
midtop,midleft,midbottom,midright
中心,centerx,centery
尺寸,宽度,高度
W,H
我加粗center
。