本文整理汇总了Python中animation.Animation.kill方法的典型用法代码示例。如果您正苦于以下问题:Python Animation.kill方法的具体用法?Python Animation.kill怎么用?Python Animation.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类animation.Animation
的用法示例。
在下文中一共展示了Animation.kill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import kill [as 别名]
#.........这里部分代码省略.........
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
def toggle_shake(self, b=None):
"""
Toggle screen shaking
"""
self.shake = b if b != None else not self.shake
def __handle_collisions__(self):
"""
Handle permitted collisions, such
as those between player and items/enemies
and between enemies and items.
Non-permitted collisions such as
player and collideables or enemies and
collideables will be handle by player
and enemy classes respectively.