Pygame 缩放精灵 [英] Pygame scaling a sprite

查看:95
本文介绍了Pygame 缩放精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将精灵的图像放大或缩小?我可以更改矩形和所有内容,但不能更改图像.

How would one scale a sprite's image to be bigger or smaller? I can change the rect and all, but not the image.

代码:(虽然我不确定你为什么需要它)

Code:(though i'm not sure why you would need it for this)

class test(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("testImage.png").convert()
        self.image.set_colorkey((255,255,255))
        self.rect = self.image.get_rect()

推荐答案

你试过了吗

pygame.transform.scale()

官方文档说明你应该使用这个语法:

Official documentation notes that you should use this syntax:

scale(Surface, (width, height), DestSurface = None) -> Surface

这篇关于Pygame 缩放精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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