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


Python clock.schedule_once函数代码示例

本文整理汇总了Python中pyglet.clock.schedule_once函数的典型用法代码示例。如果您正苦于以下问题:Python schedule_once函数的具体用法?Python schedule_once怎么用?Python schedule_once使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self,
                 img, x=0, y=0, z=0,
                 blend_src=GL_SRC_ALPHA,
                 blend_dest=GL_ONE_MINUS_SRC_ALPHA,
                 batch=None,
                 group=None,
                 usage='dynamic',
                 subpixel=False,
                 alpha_test_val=0.5):
        '''Create a sprite with z-coordinate support.

        :Parameters:
            `img` : `AbstractImage` or `Animation`
                Image or animation to display.
            `x` : int
                X coordinate of the sprite.
            `y` : int
                Y coordinate of the sprite.
            `z` : int
                Z coordinate of the sprite.
            `blend_src` : int
                OpenGL blend source mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            `blend_dest` : int
                OpenGL blend destination mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            `batch` : `Batch`
                Optional batch to add the sprite to.
            `group` : `Group`
                Optional parent group of the sprite.
            `usage` : str
                Vertex buffer object usage hint, one of ``"none"`` (default),
                ``"stream"``, ``"dynamic"`` or ``"static"``.  Applies
                only to vertex data.

        '''
        if batch is not None:
            self._batch = batch

        self._x = x
        self._y = y
        self._z = z
        
        self._alpha_test_val = alpha_test_val

        if isinstance(img, image.Animation):
            self._animation = img
            self._frame_index = 0
            self._texture = img.frames[0].image.get_texture()
            self._next_dt = img.frames[0].duration
            if self._next_dt:
                clock.schedule_once(self._animate, self._next_dt)
        else:
            self._texture = img.get_texture()

        # Must use the ZSpriteGroup to be able to enable depth testing
        self._group = ZSpriteGroup(self._alpha_test_val, self._texture, blend_src, blend_dest, group)
        self._usage = usage
        self._subpixel = subpixel
        self._create_vertex_list()
开发者ID:NiclasEriksen,项目名称:rpg_procgen,代码行数:60,代码来源:zsprite.py

示例2: next_text

 def next_text(self, _):
     self.textidx += 1
     self.textidx %= len(texts)
     delay = 1.5
     if self.text == '':
         delay = 0.5
     clock.schedule_once(self.next_text, delay)
开发者ID:mjs,项目名称:brokenspell,代码行数:7,代码来源:hudinstructions.py

示例3: __init__

    def __init__(self, x, y):
        dst = 50
        num = 10
        dt = .6
        fscale = 1
        by = 360.0/num
        self.images = []
        for i in range(num):
            ang = i*by
            rad = ang / 180.0 * math.pi
            s = simage.SImage('wedge.png', x, y)
            s.sp.x = rabbyt.lerp(end=math.cos(rad)*dst*fscale+x, dt=dt)
            s.sp.y = rabbyt.lerp(end=math.sin(rad)*dst*fscale+y, dt=dt)
            '''cool things:
            #1
            s.sp.rot = ang - 90

            #2
            s.sp.rot = ang

            #3
            s.sp.rot = ang + 90
            '''
            s.sp.rot = rabbyt.lerp(ang, ang - 90.0, dt=dt/2)
            s.sp.rot = rabbyt.lerp(ang + 90, ang - 90.0, dt=dt)
            #s.sp.rot = ang - 90.0
            s.sp.scale = rabbyt.lerp(0,fscale,dt=dt)
            self.images.append(s)
        self.on = True
        def tmp(dt):
            l = rabbyt.lerp(1.0,0.0,dt=dt)
            for i in self.images:
                i.sp.alpha = l#rabbyt.lerp(1.0,0.0,dt=1)
            clock.schedule_once(self.off, dt)
        clock.schedule_once(tmp, dt/2)
开发者ID:jaredly,项目名称:GameCC,代码行数:35,代码来源:game.py

示例4: __init__

    def __init__(self,
                 img, x=0, y=0,
                 blend_src=GL_SRC_ALPHA,
                 blend_dest=GL_ONE_MINUS_SRC_ALPHA,
                 batch=None,
                 group=None,
                 usage='dynamic',
                 subpixel=False):
        '''Create a sprite.

        :Parameters:
            `img` : `AbstractImage` or `Animation`
                Image or animation to display.
            `x` : int
                X coordinate of the sprite.
            `y` : int
                Y coordinate of the sprite.
            `blend_src` : int
                OpenGL blend source mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            `blend_dest` : int
                OpenGL blend destination mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            `batch` : `Batch`
                Optional batch to add the sprite to.
            `group` : `Group`
                Optional parent group of the sprite.
            `usage` : str
                Vertex buffer object usage hint, one of ``"none"`` (default),
                ``"stream"``, ``"dynamic"`` or ``"static"``.  Applies
                only to vertex data.
            `subpixel` : bool
                Allow floating-point coordinates for the sprite. By default,
                coordinates are restricted to integer values.

        '''
        if batch is not None:
            self._batch = batch

        self._x = x
        self._y = y

        if isinstance(img, image.Animation):
            self._animation = img
            self._frame_index = 0
            self._texture = img.frames[0].image.get_texture()
            self._next_dt = img.frames[0].duration
            if self._next_dt:
                clock.schedule_once(self._animate, self._next_dt)
        else:
            self._texture = img.get_texture()

        ## MY ADDITION - set anchor in center
        self._texture.anchor_x = self._texture.width/2
        self._texture.anchor_y = self._texture.height/2

        self._group = SpriteGroup(self._texture, blend_src, blend_dest, group)
        self._usage = usage
        self._subpixel = subpixel
        self._create_vertex_list()
开发者ID:satzen,项目名称:MiEngine,代码行数:60,代码来源:sprite.py

示例5: __init__

 def __init__(self, x, y, dx, _, owner):
     WorldItem.__init__(self, x, y, 0, 0)
     self.rotation = 0
     self.speed = copysign(uniform(5, 52), -dx)
     self.curve = uniform(0.002, 0.02)
     self.owner = owner
     clock.schedule_once(lambda _: self.reset_owner(), 1)
开发者ID:mjs,项目名称:brokenspell,代码行数:7,代码来源:feather.py

示例6: start

    def start(self):
        self._remove_last_games_items()

        self.wave = 0
        Player.start_game()
        self.add(HudInstructions())
        clock.schedule_once(lambda _: self.spawn_wave(), 2)
开发者ID:tartley,项目名称:sinister-ducks,代码行数:7,代码来源:game.py

示例7: on_key_press

def on_key_press(symbol, modifiers):
  global lastKeyPressed
  #for now escape quits
  if symbol == key.ESCAPE: InitGL.win.has_exit = True
  lastKeyPressed = (symbol, modifiers)
  Nodes.canvas.focused.keydown = (symbol, modifiers)
  #set up keyrate timer - on_key_release removes it
  clock.schedule_once(repeatKey, 0.4)
开发者ID:circlecycle,项目名称:pyroglyph,代码行数:8,代码来源:Events.py

示例8: _level_anime

 def _level_anime(dt, self):
     if self.level_anime <= 3:
         self.level_anime += 1
         clock.schedule_once(self._level_anime, 2, self)
     else:
         self.level_anime = -1
     if DEBUG:
         print 'LEVEL END ANIMATION (%s)' %(self.level_anime)
开发者ID:jseutter,项目名称:getoffmylawn,代码行数:8,代码来源:game.py

示例9: __init__

 def __init__(self, difficulties, camera):
     self.difficulties = difficulties
     self.counter = 0
     self.labels = deque()
     self.credit_it = self.credit_text()
     self.camera = camera
     schedule_interval(self.update_position, 0.017)
     schedule_once(self.update_text, 0)
开发者ID:jribbens,项目名称:wasabi-root,代码行数:8,代码来源:credits.py

示例10: scene1

def scene1():
    print "scene1"
    s.Narration('Sending me into the snow-storm')
    s.Narration('Without any help')
    s.Narration('Again')
    s.Narration('Alone')
    clock.schedule_interval(spawn_troll, 5)
    clock.schedule_once(scene2, 20)
开发者ID:dragonfi,项目名称:ld25-you-are-the-hero,代码行数:8,代码来源:script.py

示例11: on_key_press

def on_key_press(symbol,modifiers):
    if symbol == key.Q:
        pyglet.app.exit()
    if symbol in valid_keys:
        if move_robber(symbol):
            clock.schedule_once(move_cop0, cop_delay)
            clock.schedule_once(move_cop1, cop_delay * 2)
            game_state.print_locations()
开发者ID:krismanaya,项目名称:Cops-and-Robbers-,代码行数:8,代码来源:game.py

示例12: next_frame

 def next_frame(self, dt):
     self.index = (self.index + 1) % len(self.animation.frames)
     frame = self.animation.frames[self.index]
     if frame.duration is not None:
         delay = frame.duration - (self.expected_delay - dt)
         delay = min(max(0, delay), frame.duration)
         clock.schedule_once(self.next_frame, delay)
         self.expected_delay = delay
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:8,代码来源:animation.py

示例13: make_shape_animations

 def make_shape_animations(self):
     x, y = get_xy_positions(self.win.width, self.win.height)
     s = SImage(get_random_image(), x, y)
     s.sp.x = rabbyt.lerp(end=random.uniform(0, self.win.width), dt=1)
     s.sp.y = rabbyt.lerp(end=random.uniform(0, self.win.height), dt=1)
     s.sp.rot = rabbyt.lerp(start=0, end=360, dt=1)
     s.sp.scale = rabbyt.lerp(.25, 1, dt=1)
     self.world.objects.append(s)
     clock.schedule_once(lambda dt:self.world.objects.remove(s), 1)
开发者ID:matthewturner,项目名称:babytux,代码行数:9,代码来源:game.py

示例14: spawn

 def spawn(self, dt=None, set_health=True):
     point = self._determine_spawn(self.team)
     if point is not None: #will return None if all the gates have been destroyed
         self.position, self.forward, self.up = point.position + point.forward * 5, point.forward, point.up
         self.velocity = Vector3(0,0,0)
         if set_health:
             self.health, self.dead = 100, False
     else:
         clock.schedule_once(self.spawn, 5)
开发者ID:dummey,项目名称:CSE125,代码行数:9,代码来源:player.py

示例15: controller_changed

 def controller_changed(self, sender, original):
     start_zone = self.play_zones[original]
     end_zone = self.play_zones[sender.controller]
     guicard = start_zone.get_card(sender)
     start_pos = self.project_to_window(*tuple(start_zone.pos+guicard.pos))
     start_zone.remove_card(sender, clock)
     guicard = end_zone.add_card(sender,startt=1.6)
     end_pos = self.project_to_window(*tuple(end_zone.pos+guicard.pos))
     clock.schedule_once(lambda t: self.sparks.add_spark(start_pos, end_pos, dt=1., color=str(sender.color)), 0.7)
开发者ID:Incantus,项目名称:incantus,代码行数:9,代码来源:animator.py


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