本文整理汇总了Python中sprites.Sprite.get_dimensions方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.get_dimensions方法的具体用法?Python Sprite.get_dimensions怎么用?Python Sprite.get_dimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sprites.Sprite
的用法示例。
在下文中一共展示了Sprite.get_dimensions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sprites import Sprite [as 别名]
# 或者: from sprites.Sprite import get_dimensions [as 别名]
class Tile:
def __init__(self, sprites, svg, svgs, tile_type='tile', number=0):
self.highlight = [svg_str_to_pixbuf(svg)]
self.spr = Sprite(sprites, 0, 0, self.highlight[0])
for s in svgs:
self.highlight.append(svg_str_to_pixbuf(s))
self.paths = [] # [[N, E, S, W], [N, E, S, W]]
self.shape = None
self.orientation = 0
self.type = tile_type
self.number = number
self.value = 1
self.spr.set_label_color('#FF0000')
def set_value(self, value):
self.value = value
def get_value(self):
return self.value
def set_paths(self, paths):
for c in paths:
self.paths.append(c)
def get_paths(self):
return self.paths
def reset(self):
self.spr.set_layer(HIDE)
self.shape = None
self.spr.set_shape(self.highlight[0])
while self.orientation != 0:
self.rotate_clockwise()
def set_shape(self, path):
if self.shape is None:
self.spr.set_shape(self.highlight[path + 1])
self.shape = path
elif self.shape != path:
self.spr.set_shape(self.highlight[-1])
def rotate_clockwise(self):
""" rotate the tile and its paths """
for i in range(len(self.paths)):
west = self.paths[i][WEST]
self.paths[i][WEST] = self.paths[i][SOUTH]
self.paths[i][SOUTH] = self.paths[i][EAST]
self.paths[i][EAST] = self.paths[i][NORTH]
self.paths[i][NORTH] = west
for h in range(len(self.highlight)):
self.highlight[h] = self.highlight[h].rotate_simple(270)
self.spr.set_shape(self.highlight[0])
self.orientation += 90
self.orientation %= 360
def show_tile(self):
self.spr.set_layer(CARDS)
def hide(self):
self.spr.move((-self.spr.get_dimensions()[0], 0))