Pygame rect.inflate 功能似乎不起作用

Pygame rect.inflate function does not seem to work

Pygame 的“rect.inflate_ip”功能如何运作?
在这段代码中,我试图将这个矩形膨胀一些值 zoom:

rect = pygame.draw.rect(screen,block.color,(block.x+scx,block.y+scy,10,10))
rect.inflate_ip(zoom,zoom) 

但这没有任何作用。为什么?

inflate_ip 之前和之后打印 rect,您会看到区别。当然,它不会影响屏幕上绘制的矩形。 pygame.draw.rect does not generate an object. This function fills a rectangular area on the screen and returns that area. You have to create a pagame.Rect 对象并将其用于绘图。例如:

rect = pygame.Rect(block.x+scx, block.y+scy, 10, 10)
rect.inflate_ip(zoom, zoom) 
pygame.draw.rect(screen, block.color, rect)