【问题标题】:Pygame rect=rect.inflate() vs rect.inflate_ip() [duplicate]Pygame rect=rect.inflate() vs rect.inflate_ip() [重复]
【发布时间】:2016-03-31 12:30:02
【问题描述】:

我是 python 和 pygame 的新手。为什么我应该将inflate() 方法分配给一个新的矩形对象:

rectObj=rectObj.inflate()

在使用inflate_ip() 时,我不需要将其分配给任何变量,但仅调用该方法实际上会更改对象:

rectObj.inflate_ip()

有什么区别,我的意思是它更像 pythonic 而不是 pygamic(我知道 inflate 做了什么)。

【问题讨论】:

    标签: python python-2.7 pygame


    【解决方案1】:

    rectObj.inflate() 返回另一个矩形,因此您将名称“rectObj”重新绑定到新矩形。

    inflate_ip() 做同样的事情,但在适当的位置 ('ip')。我会使用第二个,除非您想为膨胀的矩形创建一个不同的名称

    查看这里,注意每个方法返回的内容http://www.pygame.org/docs/ref/rect.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 1970-01-01
      • 2011-11-04
      • 1970-01-01
      • 2018-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多