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


Python Timer.reset方法代码示例

本文整理汇总了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()
开发者ID:Fenixin,项目名称:yogom,代码行数:30,代码来源:actionsprite.py

示例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
开发者ID:Fenixin,项目名称:yogom,代码行数:44,代码来源:actionsprite.py

示例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()
开发者ID:Fenixin,项目名称:yogom,代码行数:41,代码来源:actionsprite.py


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