.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()

相关文章:

  • 2021-08-27
  • 2021-10-24
  • 2021-06-01
  • 2021-10-12
  • 2021-08-14
  • 2021-07-06
  • 2021-11-16
  • 2021-11-27
猜你喜欢
  • 2021-11-06
  • 2021-08-11
  • 2021-04-12
  • 2021-12-22
  • 2021-11-17
  • 2021-12-23
  • 2021-06-24
相关资源
相似解决方案