本文整理匯總了Python中utils.Timer.reset方法的典型用法代碼示例。如果您正苦於以下問題:Python Timer.reset方法的具體用法?Python Timer.reset怎麽用?Python Timer.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.Timer
的用法示例。
在下文中一共展示了Timer.reset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ToggleAnimation
# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import reset [as 別名]
class ToggleAnimation(AnimationActionSprite, Triggered):
"Animation that can be toggled on/off. """
def __init__(self, **others):
Triggered.__init__(self, **others)
AnimationActionSprite.__init__(self, **others)
self.debugging = False
self.playing = False
self.timer = Timer(0.2)
self.animation_player.backwards = True
def update(self, player, collisions_group, **others):
self.dprint("\n### ToggleAnimation.update()")
e = self.get_trigger(self.triggered_code)
self.dprint("\tEvent:" + str(e))
if self.timer.finished and e:
self.timer.reset()
self.dprint("\t\tToggling Animation")
if self.playing:
self.dprint("\t\t\tDeactivating animation")
self.playing = False
else:
self.dprint("\t\t\tActivating animation")
self.playing = True
if self.playing:
self.next_frame()
示例2: ToggleText
# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import reset [as 別名]
class ToggleText(TextActionSprite, Triggered):
""" Text that toggles on/off when a trigger event is received.
Special parameters are:
- Delay: amount of time to wait before you can toggle the text
again.
"""
def __init__(self, **others):
Triggered.__init__(self, **others)
TextActionSprite.__init__(self, **others)
# custom parameters
self.custom_properties = { "Delay" : {"type" : float, "destination" : "delay"} }
self.parse_catching_errors(self.custom_properties, others, self.__dict__)
# create the timer
self.timer = Timer(self.delay)
# prints lots of debugging text
self.debugging = False
def update(self, player, collisions_group, **others):
self.dprint("\n### TriggeredText.update()")
e = self.get_trigger(self.triggered_code)
self.dprint("\tEvent:" + str(e))
if e and self.timer.finished:
self.timer.reset()
self.dprint("\t\tToggling text")
if self.showing:
self.update_position(player)
self.dprint("\t\t\tDeactivating text")
self.showing = False
else:
self.update_position(player)
self.dprint("\t\t\tActivating text")
self.showing = True
self.update_alpha()
def do(self):
pass
示例3: PingPongTriggeredAnimation
# 需要導入模塊: from utils import Timer [as 別名]
# 或者: from utils.Timer import reset [as 別名]
class PingPongTriggeredAnimation(OnceAnimationActionSprite, Triggered):
""" Animation that tries to be always in start or the end of the
animation. Kind of an animation of a lever, the lever can be
switched on/off but alawys end up in the start or end position.
"""
def __init__(self, **others):
Triggered.__init__(self, **others)
OnceAnimationActionSprite.__init__(self, **others)
self.debugging = False
self.playing = False
self.timer = Timer(0.2)
self.debugging = False
def do(self):
pass
def update(self, player, collisions_group, **others):
self.dprint("\n### PingPongAnimation.update()")
e = self.get_trigger(self.triggered_code)
self.dprint("\tEvent:" + str(e))
if e and self.timer.finished:
#~ import pdb; pdb.set_trace()
self.dprint("\t\tToggling Animation")
self.timer.reset()
if self.animation_player.finished:
#~ import pdb; pdb.set_trace()
self.animation_player.finished = False
self.animation_player.backwards = not self.animation_player.backwards
else:
if self.animation_player.backwards:
self.animation_player.backwards = False
else:
self.animation_player.backwards = True
self.next_frame()