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


Python Animation.start方法代码示例

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


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

示例1: __init__

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
    def __init__(self):
        super(Splash, self).__init__()
        self.next_state = "SHOOTING"
        self.animations = pg.sprite.Group()
        with open(os.path.join("resources", "clay_spots.json"), "r") as f:
            skeet_spots = json.load(f)
        self.all_sprites = pg.sprite.LayeredUpdates()
        self.clays = pg.sprite.OrderedUpdates()
        delay = 0
        duration = 500
        depth = 5000
        for spot in skeet_spots:
            clay = ClayPigeon((640, 750), 7, 0, False, self.clays, self.all_sprites)
            clay.rect.center = 640, 750
            clay.z = depth
            x, y = spot
            ani = Animation(centerx=x, centery=y, duration=duration, delay=delay, round_values=True)
            ani.start(clay.rect)
            self.animations.add(ani)

            delay += 15
            depth -= 1

        self.world = World(False)
        for s in self.all_sprites:
            self.all_sprites.change_layer(s, -s.z)
        try:
            with open(os.path.join("resources", "high_scores.json"), "r") as f:
                high_scores = json.load(f)
        except IOError:
            with open(os.path.join("resources", "high_scores.json"), "w") as f:
                json.dump([], f)
开发者ID:metulburr,项目名称:skeet-shoot-challenge,代码行数:34,代码来源:splash.py

示例2: startup

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def startup(self, persistent):
     self.persist = persistent
     self.shade_alpha = 255
     ani = Animation(shade_alpha=0, duration=3000,
                             round_values=True, transition="linear")
     ani.start(self)
     self.animations.add(ani)
开发者ID:reddit-pygame,项目名称:pumpkin-carving-challenge,代码行数:9,代码来源:carving.py

示例3: shoot

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def shoot(self, bullets, turkeys, all_sprites, animations):
     """
     Fire a bullet if the player has enough ammo and enough time has passed
     since the last shot.
     """
     if self.cooldown_timer >= self.cooldown_time:
         self.stop_walking()
         if self.shells <= 0:
             prepare.SFX["gunclick"].play()
         else:
             self.shells -= 1
             prepare.SFX["gunshot"].play()
             pos = project(self.pos, (self.angle - .1745) % (2 * pi), 42) #end of rifle at 96x96
             bullet  = Bullet(pos, self.angle, bullets, all_sprites)
             distance = 2000.
             x, y  = project(pos, self.angle, distance)
             ani = Animation(centerx=x, centery=y, duration=distance/bullet.speed, round_values=True)
             ani.callback = bullet.kill
             ani.start(bullet.rect)
             animations.add(ani)
             scare_rect = self.collider.inflate(1200, 1200)
             scared_turkeys = [t for t in turkeys if scare_rect.colliderect(t.collider)]
             for scared in scared_turkeys:
                 task = Task(scared.flee, 750, args=(self,))
                 self.animations.add(task)
         task = Task(self.flip_state, 120, args=("idle",))
         animations.add(task)
         self.cooldown_timer = 0
         self.flip_state("shoot")
开发者ID:reddit-pygame,项目名称:turkey-shoot-challenge,代码行数:31,代码来源:hunter.py

示例4: make_ani

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def make_ani(self, minute_length):
     dest = next(self.ends)
     x_trans, y_trans = next(self.transitions)
     duration = minute_length * 60 * 6
     ani = Animation(centerx=dest[0], duration=duration,
                              transition=x_trans, round_values=True)
     ani2 = Animation(centery=dest[1], duration=duration,
                               transition=y_trans, round_values=True)
     task = Task(self.make_ani, duration, args=(minute_length,))
     ani.start(self.rect)
     ani2.start(self.rect)
     self.animations.add(ani, ani2, task)
开发者ID:metulburr,项目名称:skeet-shoot-challenge,代码行数:14,代码来源:world.py

示例5: __init__

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def __init__(self, leader_centerpoint, animations, all_sprites, *groups):
     super(Flock, self).__init__(*groups)
     x, y  = leader_centerpoint
     for offset in self.offsets:
         center = x + offset[0], y + offset[1]
         duck = Duck(center, all_sprites)
         if offset == (0, 0):
             self.leader = duck
         dest = duck.rect.y + (prepare.WORLD_SIZE[1] * 2)
         ani = Animation(y=dest, duration=self.fly_time, round_values=True)
         ani.callback = duck.kill
         ani.start(duck.rect)
         flap_time = randint(100, 150)
         task = Task(duck.flap, flap_time, self.fly_time // flap_time)
         animations.add(ani, task)
     finish = Task(self.kill, self.fly_time + 100)
     animations.add(finish)
     self.honked = False
开发者ID:CanuckMonkey,项目名称:turkey-shoot-challenge,代码行数:20,代码来源:helpers.py

示例6: move_left

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
    def move_left(self, widget):
        '''
        Internal callback function to "clicked" signal.

        @param widget: Left button.
        '''
        upper, page_size, value = self.adj.upper, self.adj.page_size, self.adj.value
        shift_value = 0
        temp = 0
        if not value == 0:
            self.right_btn.show()
            for i in xrange(len(self.item_list)):
                temp += self.item_list[i]
                if temp >= value:
                    shift_value = self.item_list[i] - (temp - value)
                    break
            #play animation
            ani = Animation(self.adj, lambda widget, v1: widget.set_value(v1),200,[value, value-shift_value])
            ani.start()
        if (self.adj.value - shift_value) == 0:
            self.left_btn.hide()
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:23,代码来源:breadcrumb.py

示例7: move_right

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
    def move_right(self, widget):
        '''
        Internal callback function to "clicked" signal.

        @param widget: Right button.
        '''
        upper, page_size, value = self.adj.upper, self.adj.page_size, self.adj.value
        shift_value = 0
        temp = 0
        if upper > (page_size + value):
            self.left_btn.show()
            for i in xrange(len(self.item_list)+1):
                temp += self.item_list[i]
                if temp > (page_size + value):
                    shift_value = temp - (page_size + value)
                    #play animation
                    ani = Animation(self.adj, lambda widget, v1: widget.set_value(v1),200,[value, value+shift_value])
                    ani.start()
                    break
        if not upper > (page_size + self.adj.value + shift_value):
            self.right_btn.hide()
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:23,代码来源:breadcrumb.py

示例8: add_chair

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def add_chair(self, midbottom, direction):
     """Add a single chair to the chairlift."""
     centerx, bottom = midbottom
     if direction == "up":
         x_offset = 18
         destination = self.top_lifthut.rect.bottom + 10 
         distance = bottom - destination
         klass = UpChair
     elif direction == "down":
         x_offset = -19
         destination = self.bottom_lifthut.rect.top + 70
         distance = destination - bottom
         klass = DownChair
     duration = distance * 30
     chair = klass((centerx + x_offset, bottom), self.chairs)
     ani = Animation(bottom=destination, duration=duration, round_values=True)
     opposite = "up" if direction == "down" else "down"
     ani.start(chair.rect)
     ani.callback = chair.kill
     task = Task(self.recycle_chair, interval=duration, args=(opposite,))
     self.animations.add(ani, task)
开发者ID:reddit-pygame,项目名称:snowboard-challenge,代码行数:23,代码来源:chairlift.py

示例9: add_leaf

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
 def add_leaf(self, tree, spot_info):
     """Add a falling leaf."""
     fall_time = randint(2000, 2500)
     leaf = Leaf(tree, spot_info, self.leaves, self.all_sprites)
     y = leaf.rect.centery + leaf.fall_distance
     ani = Animation(centery=y, duration=fall_time, round_values=True)
     ani.callback = leaf.land
     ani.start(leaf.rect)
     ani2 = Animation(centery=leaf.collider.centery + leaf.fall_distance,
                                duration=fall_time, round_values=True)
     ani2.start(leaf.collider)
     fade = Animation(img_alpha=0, duration=3000, delay=fall_time,
                               round_values=True)
     fade.callback = leaf.kill
     fade.update_callback = leaf.set_alpha
     fade.start(leaf)
     self.animations.add(ani, ani2, fade)
开发者ID:reddit-pygame,项目名称:turkey-shoot-challenge,代码行数:19,代码来源:hunting.py

示例10: __init__

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]

#.........这里部分代码省略.........

        """
        
        # left
        collided = None
        if x < 0:
            collided = collide_left
            if wall_check:
                if obj.rect.left <= 0: 
                    return False
        # right
        if x > 0:
            collided = collide_right
            if wall_check:
                if obj.rect.right >= self.width:
                    return False
        # bottom 
        if y > 0:
            collided = collide_bottom

        # top 
        if y < 0:
            collided = collide_top

        return len(
                pygame.sprite.spritecollide(
                    obj, self.collideables, False, collided)) < 1

    def set_animation(self, tgt_x, tgt_y, delay=0):
        self.ani = Animation(x=tgt_x, y=tgt_y, transition='out_expo',
            duration=800, delay=delay)


    def start_animation(self):
        if self.ani != None:
            # self.ani.delay = random() * 5
            self.ani._elapsed = .0
            self.ani.start(self.focus)


    def set_focus(self, rect, horz=True, vert=False, offsetx=0, offsety=0, animate=True):
        """
            Set camera focus to on object or rect.
            If object is given, object must have rect property.

            @horz       = boolean, focus horizontally (appears centered x)
            @vert       = boolean, focus vertically (appears centered y)
        """
        if horz or vert:
            assert isinstance(rect, pygame.Rect)
            if self.ani:
                self.ani.kill()
            if animate:
                self.set_animation(rect.x, rect.y)
                self.target_focus = rect
                self.start_animation()
            else:
                self.focus = rect
            self.hz_focus = horz
            self.vt_focus = vert
            self.focus_offsetx = offsetx
            self.focus_offsety = offsety

    def remove_focus(self):
        self.focus = pygame.Rect(0,0,0,0)
        self.ani = None
开发者ID:emelent,项目名称:pistol,代码行数:70,代码来源:world.py

示例11: Launcher

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]

#.........这里部分代码省略.........
            if self.save.available(self.current_world, self.current_menu_item):
                self.level_id = self.current_menu_item
                self.play()
            else:
                return False

        return True

    def read_level_info(self):
        filenames = glob(os.path.join('levels', '*.txt'))
        self.worlds = {}
        for filename in filenames:
            try:
                world = LevelSet(filename)
            except IOError:
                continue
            self.worlds[world.name] = world

    def play(self):
        self.save.set_current(self.current_world, self.level_id)
        self.mode = MODE_PLAYING
        if self.current_world == 'Tutorials':
            if self.level_id == 0:
                self.game = TutorialOne()
            elif self.level_id == 1:
                self.game = TutorialTwo()
            else:
                self.game = game.Game()
        else:
            self.game = game.Game()
        self.renderer = Renderer()
        self.game.loc_from_screen_coords = self.renderer.loc_from_screen_coords
        self.game.load_level(self.worlds[self.current_world].levels[self.level_id].value)
        self.game.start()

    def back(self):
        if self.mode == MODE_MAIN_MENU:
            self.quitting = True
        elif self.mode == MODE_SELECT_WORLD:
            self.mode = MODE_MAIN_MENU
        elif self.mode == MODE_SELECT_LEVEL:
            self.mode = MODE_SELECT_WORLD

    def start(self):
        self.draw()
        while not self.quitting:
            self.clock.tick(game.FRAME_RATE)
            if self.mode == MODE_PLAYING:
                self.game.main_loop()

                if self.game.stopping:
                    if self.game.won:
                        self.mode = MODE_WON
                        self.won_animation.start()
                        continue

                    self.mode = MODE_MAIN_MENU
                    self.draw()
                elif self.game.quitting:
                    self.quitting = True

            elif not self.process_events():
                continue

            self.draw()
开发者ID:fish-face,项目名称:door-restorer,代码行数:69,代码来源:launch.py

示例12: remove_animations_of

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import start [as 别名]
        pressed = pygame.key.get_pressed()
        if pressed[K_UP]:
            hero_moved = True
            hero.position.y -= .15 * avg_dt
        elif pressed[K_DOWN]:
            hero_moved = True
            hero.position.y += .15 * avg_dt

        if pressed[K_LEFT]:
            hero_moved = True
            hero.position.x -= .15 * avg_dt
        elif pressed[K_RIGHT]:
            hero_moved = True
            hero.position.x += .15 * avg_dt

        if hero_moved:
            remove_animations_of(animations, camera_position)
            ani = Animation(x=hero.position.x, y=hero.position.y,
                            duration=200, transition='out_quad')
            ani.start(camera_position)
            animations.add(ani)

        animations.update(avg_dt)
        group.update(avg_dt)
        group.center(camera_position)
        group.draw(buffer)

        pygame.transform.scale(buffer, screen.get_size(), screen)

        pygame.display.flip()
开发者ID:bitcraft,项目名称:jrpg-tutorial,代码行数:32,代码来源:jrpg.py


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