pygame 中 rect.move() 和 rect.move_ip 的区别 [英] Difference between rect.move() and rect.move_ip in pygame

查看:154
本文介绍了pygame 中 rect.move() 和 rect.move_ip 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在官方文档中浏览了 pygame 的 .rect 方法.我们有 2 个案例,

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

pygame.rect.move(arg1,arg2) 用于在屏幕上移动 .rect 对象和

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

pygame.rect.move_ip(arg1,arg2) 根据文档,也用于移动 .rect 对象在屏幕上,但它就地

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?

推荐答案

就地"表示对象自身.

虽然rect.move_ip 更改 pygame.Rect 对象本身,rect.move 可以不改变对象,但它返回一个具有相同大小和移动"位置的新对象.
注意,rect.move_ip的返回值是None,但是rect.move的返回值是一个新的pygame.Rect 对象.

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)rect = rect.move(x, y)

这篇关于pygame 中 rect.move() 和 rect.move_ip 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆