Difference between rect.move() and rect.move_ip in pygame

社会主义新天地 提交于 2020-12-25 18:21:54

问题


I was just going through the .rect method of pygame in the official docs. We have 2 cases ,

pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and

pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place

I didnt quite get what it means. Can anyone explain what move in place means?


回答1:


"In place" means the object self.

While rect.move_ip changes the pygame.Rect object itself, rect.move does not change the object, but it returns a new object with the same size and "moved" position.
Note, the return value of rect.move_ip is None, but the return value of rect.move is a new pygame.Rect object.

rect.move_ip(x, y) does the same as rect = rect.move(x, y)



来源:https://stackoverflow.com/questions/61578694/difference-between-rect-move-and-rect-move-ip-in-pygame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!