🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## .get\_rect()得到的矩形有哪些rect属性? - 返回一个坐标数字: x, y, top, left, bottom, right, centerx, centery, width, height, w, h 其中:x = left, y = top, width = w, height = h; :-: ![](https://img.kancloud.cn/47/32/4732344db8eb3f9a65f8c49cf483bb85_425x262.png) - 返回一个(X,Y)元祖 size(width, height), topleft(左上), bottomleft(左下), topright(右上), bottomright(右下),midtop(中上), midleft(左中), midbottom(底中), midright(右中),center(中心点坐标) 举个栗子,topleft就是左上角的 直接上图,灰色矩形大小(900,450),中央蓝色矩形(400,510),大家自己体会一下 :-: ![](https://img.kancloud.cn/70/95/70955ff72835f43be37d22f8a0127e64_678x413.png) ## .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()