当前位置: 首页>>代码示例>>Python>>正文


Python Sprite.scale方法代码示例

本文整理汇总了Python中sprite.Sprite.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.scale方法的具体用法?Python Sprite.scale怎么用?Python Sprite.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sprite.Sprite的用法示例。


在下文中一共展示了Sprite.scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_sprite

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import scale [as 别名]
 def load_sprite(self, file_path):
     """Calls Sprite() and checks all that it can throw"""
     try:
         sprite = Sprite(file_path)              
         sprite.scale = self.settings['scale']
         sprite.source_pixels_to_points = self.settings['source-pixels-to-points']
     except IOError:
         self.error = "Could not open file '{0}'".format(file_path)
         return None 
     else:
         return sprite
开发者ID:gustavla,项目名称:sprite-packer,代码行数:13,代码来源:packer.py

示例2: test_sprite_scale_method

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import scale [as 别名]
    def test_sprite_scale_method(self):
        surfaces = [pygame.Surface((0, 0)), pygame.Surface((0, 298)),
                    pygame.Surface((10, 0)), pygame.Surface((13, 7))]

        sprite_list = Sprite()
        sprite_list.image = pygame.Surface((1000, 1000))
        sprite_list.rect = sprite_list.image.get_rect()
        sprite_list.rect.topleft = (7, 17)
        sprite_list.images = [(surface, surface.get_rect())
                              for surface in surfaces]

        sprite_dict = Sprite()
        sprite_dict.image = pygame.Surface((23, 29))
        sprite_dict.rect = sprite_dict.image.get_rect()
        sprite_dict.rect.topleft = (0, 0)
        sprite_dict.images = {key: (surfaces[key], surfaces[key].get_rect())
                              for key in range(len(surfaces))}

        sprite_list.scale((0, 0))
        self.assertIsInstance(sprite_list, Sprite)
        self.assertEqual(sprite_list.image.get_size(), (0, 0))
        self.assertEqual(sprite_list.rect, pygame.Rect(7, 17, 0, 0))
        for image, rect in sprite_list.images:
            self.assertEqual(image.get_size(), (0, 0))
            self.assertEqual(rect, pygame.Rect(0, 0, 0, 0))

        sprite_dict.scale((2, 1))
        self.assertIsInstance(sprite_dict, Sprite)
        self.assertEqual(sprite_dict.image.get_size(), (23 * 2, 29))
        self.assertEqual(sprite_dict.rect, pygame.Rect(0, 0, 23 * 2, 29))
        for key, tuple in sprite_dict.images.items():
            self.assertEqual(tuple[0].get_size(),
                             Vec2D(surfaces[key].get_size()) * Vec2D(2, 1))
            self.assertEqual(tuple[1], pygame.Rect(0, 0,
                             surfaces[key].get_size()[0] * 2,
                             surfaces[key].get_size()[1]))
开发者ID:gshopov,项目名称:Pyruto,代码行数:38,代码来源:test_sprite.py


注:本文中的sprite.Sprite.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。