pygame rect相关知识

.get_rect()得到的矩形有哪些rect属性?

–返回一个坐标数字:
x, y, top, left, bottom, right, centerx, centery, width, height, w, h
其中:x = left, y = top, width = w, height = h;
pygame rect相关知识
示意图来源
–返回一个(X,Y)元祖
size(width, height), topleft(左上), bottomleft(左下), topright(右上), bottomright(右下),midtop(中上), midleft(左中), midbottom(底中), midright(右中),center(中心点坐标)
举个栗子,topleft就是左上角的
直接上图,灰色矩形大小(900,450),*蓝色矩形(400,510),大家自己体会一下
pygame rect相关知识
以上来自:这里

.get_rect()用法:

1、图片获取rect对象:
image = pygame.image.load(‘images/ship.bmp’)
rect = image.get_rect()
2、屏幕获取rect对象:
screen =pygame.display.set_mode((screen_width, screen_height))
screen_rect = screen.get_rect()