本文整理汇总了Python中surface.Surface.subsurface方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.subsurface方法的具体用法?Python Surface.subsurface怎么用?Python Surface.subsurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.subsurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import subsurface [as 别名]
def update(self):
self._heartLen = self._parent.getBaseHealth()
self.w, self.h = 10 * self._heartLen + 2 * ceil(self._heartLen / 2), 16
surf = Surface((self.w, self.h))
trans = self._heartFilled[0].get_at((0, 0))
surf.fill(trans)
surf.set_colorkey(trans)
self._display = Display(surface=surf, klass=self)
for i in range(self._heartLen):
self._hearts.append(surf.subsurface(Object(rect=(10 * i + 2 * (i // 2), 0, 10, 16)).asRect()))
示例2: __init__
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import subsurface [as 别名]
def __init__(self, x, y, maxTime, numNums=3):
image, width = const.numbers
numbers = Files.loadImage(image)
numbers.set_colorkey(numbers.get_at((0, 0)))
super().__init__(rect=(x, y, width * numNums, numbers.get_height()), enabled=True)
self._numbers = []
self._digits = []
self._maxTime = maxTime
self._currentTime = maxTime
self._blank = Display(Surface((width, self.h)))
for i in range(width):
self._numbers.append(Display(numbers.subsurface((i * width, 0, width, self.h))))
surf = Surface((self.w + 2 * numNums, self.h))
self._display = Display(surf, self, transparent=True, alpha=200)
for i in range(numNums):
self._digits.append(surf.subsurface((i * width + 2 * i, 0, width, self.h)))
self._lastUpdate = -maxTime