擅长:python、mysql、java
<p>有一个解决这个问题的办法,可以让你的眼睛伸展到你想要的确切宽度,但它可能会使眼睛非常变形。。。(没关系,原来的图像有相当畸形的眼睛。)</p>
<p>来自<a href="https://www.pygame.org/docs/ref/transform.html#pygame.transform.scale" rel="nofollow">pygame.transform.scale</a>上的Pygame文档:</p>
<blockquote>
<p>scale(Surface, (width, height), DestSurface = None) -> Surface</p>
</blockquote>
<p>我们还使用image.<a href="https://www.pygame.org/docs/ref/surface.html#pygame.Surface.get_height" rel="nofollow">get_height</a>(),这样用户就不必自己获取高度。在</p>
<p>因此,您可以执行以下操作(封装在函数中):</p>
<pre><code>def stretchEyes(image, newWidth):
return pygame.transform.scale(image, (image.get_height(), newWidth))
eyes = stretchEyes(eyes, image.get_width()*3) # Stretch to three times width
# Blitting takes in the top left position, so we don't need to do any maths here!
screen.blit(eyes, (x,y))
</code></pre>