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


Python Animation.add_frame方法代码示例

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


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

示例1: read_animation_def

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import add_frame [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
开发者ID:bitcraft,项目名称:fighter-framework,代码行数:59,代码来源:loader.py

示例2: make_banner

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import add_frame [as 别名]
 def make_banner(self):
     banner_x = 322 / 2 - (self.banner_image[1].width / 2)
     banner = SimpleAvatar()
     banner.position = (banner_x, 80)
     bf = AnimationFrame()
     bf.image, bf.rect = self.banner_image
     bf.ttl = 1500
     ani = Animation()
     ani.add_frame(bf)
     banner.add_animation(ani)
     self.world.add(banner)
     banner.callback = (self.close_banner, [])
     return banner
开发者ID:bitcraft,项目名称:fighter-framework,代码行数:15,代码来源:match.py

示例3: __init__

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import add_frame [as 别名]
    def __init__(self, speed, starting_position, texture, window_rectangle, collision_manager):
        self.window_rectangle = window_rectangle
        self.starting_position = starting_position
        self.speed = speed
        self.collision_manager = collision_manager
        self.direction = 1 if speed > 0 else -1

        # Plane
        fly_anim = Animation()
        fly_anim.texture = texture
        fly_anim.add_frame(sf.Rectangle((0, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((176, 0), (88, 73)))
        fly_anim.add_frame(sf.Rectangle((88, 0), (88, 73)))

        self.plane = AnimatedSprite(sf.seconds(0.2), False, True)
        self.plane.play(fly_anim)
        self.plane.size = sf.Vector2(self.plane.global_bounds.width / 2, self.plane.global_bounds.height / 2)
        self.plane.origin = self.plane.global_bounds.width / 2.0, self.plane.global_bounds.height / 2.0
        self.plane.scale((self.direction * 0.5, 0.5))

        self.plane.position = self.starting_position
        self.plane_speed = sf.Vector2(speed, 0)

        self.is_dead = False
        self.jump_time = None
        self.plane_jumped = False

        self.immortal = None

        self.bullets = set()

        SoundManager.play_player_appear_sound()
开发者ID:Valian,项目名称:IGK2015,代码行数:35,代码来源:player.py


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