Pygaem.rect

屬性 & 方法

pygame.Rect.copy() — 拷貝 Rect 對象
pygame.Rect.move() — 移動 Rect 對象
pygame.Rect.move_ip() — 原地移動 Rect 對象
pygame.Rect.inflate() — 放大和縮小 Rect 對象的尺寸
pygame.Rect.inflate_ip() — 原地放大和縮小 Rect 對象的尺寸
pygame.Rect.clamp() — 將一個 Rect 對象移動到另一個 Rect 對象的中心
pygame.Rect.clamp_ip() — 原地將一個 Rect 對象移動到另一個 Rect 對象的中心
pygame.Rect.clip() — 獲取兩個 Rect 對象互相重疊的部分
pygame.Rect.union() — 將兩個 Rect 對象合併
pygame.Rect.union_ip() — 原地將兩個 Rect 對象合併
pygame.Rect.unionall() — 將多個 Rect 對象合併
pygame.Rect.unionall_ip() — 原地將多個 Rect 對象合併
pygame.Rect.fit() — 按照一定的寬高比調整 Rect 對象
pygame.Rect.normalize() — 翻轉 Rect 對象(如果尺寸爲負數)
pygame.Rect.contains() — 檢測一個 Rect 對象是否完全包含在該 Rect 對象內
pygame.Rect.collidepoint() — 檢測一個點是否包含在該 Rect 對象內
pygame.Rect.colliderect() — 檢測兩個 Rect 對象是否重疊
pygame.Rect.collidelist() — 檢測該 Rect 對象是否與列表中的任何一個矩形有交集
pygame.Rect.collidelistall() — 檢測該 Rect 對象與列表中的每個矩形是否有交集
pygame.Rect.collidedict() — 檢測該 Rect 對象是否與字典中的任何一個矩形有交集
pygame.Rect.collidedictall() — 檢測該 Rect 對象與字典中的每個矩形是否有交集


Pygame 通過 Rect 對象存儲和操作矩形區域。一個 Rect 對象可以由 left,top,width,height
幾個值創建。Rect 也可以是由 Pygame 的對象所創建,它們擁有一個屬性叫“rect”。


爲了方便大家移動和對齊,Rect 對象提供以下這些虛擬屬性:

x,y
top, left, bottom, right
topleft(左下), bottomleft, topright, bottomright
midtop(中間的頂部), midleft, midbottom, midright
center(中心), centerx, centery
size, width, height

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章