本文整理汇总了Python中animation.Animation.hold_loop方法的典型用法代码示例。如果您正苦于以下问题:Python Animation.hold_loop方法的具体用法?Python Animation.hold_loop怎么用?Python Animation.hold_loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类animation.Animation
的用法示例。
在下文中一共展示了Animation.hold_loop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_animation_def
# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import hold_loop [as 别名]
def read_animation_def(filename, name, frame_klass=AnimationFrame):
reader = ConfigObj(filename)
animation = Animation(name)
path = os.path.split(filename)[0]
range_regex = re.compile(".*?(\d*)\s*-\s*(\d*)")
# stores information that affects all frames in the animation
animation_dict = {}
try:
animation_dict.update(reader['general'])
except KeyError:
pass
for section, values in reader.items():
d = {}
# update for the "globals"
d.update(animation_dict)
d.update(values)
if section[:5].lower() == "frame":
start = None
end = None
try:
# frames can define a range of frames
start, end = range_regex.match(section).groups()
start = int(start)
end = int(end)
except AttributeError:
pass
# load a single frame
if start == None:
d['name'] = section[6:]
frame = load_frame(path, d, frame_klass)
animation.add_frame(frame)
# load a range of frames
else:
prefix, suffix = get_frame_image_filename_prefix_suffix(d)
for x in range(start, end + 1):
# mangle the dict to reflect the right image_file
d['file'] = prefix + str(x) + suffix
d['name'] = str(x)
frame = load_frame(path, d, frame_klass)
animation.add_frame(frame)
if section.lower() == "animation":
# loop entire animation when held
animation.hold_loop = handle_bool(d, 'hold loop')
# play while held [stop when let go]
animation.hold_play = handle_bool(d, 'hold play')
return animation