How to use the ursina.sequence.Wait function in ursina

To help you get started, we’ve selected a few ursina examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pokepetter / ursina / ursina / entity.py View on Github external
pass
        setattr(self, animator_name, Sequence(time_step=time_step))
        sequence = getattr(self, animator_name)
        self.animations.append(sequence)
        # sequence.append(Wait(delay))
        if not resolution:
            resolution = max(int(duration * 60), 1)

        for i in range(resolution+1):
            t = i / resolution
            # if isinstance(curve, CubicBezier):
            #     t = curve.calculate(t)
            # else:
            t = curve(t)

            sequence.append(Wait(duration / resolution))
            sequence.append(Func(setattr, self, name, lerp(getattr(self, name), value, t)))

        sequence.start()
        return sequence
github pokepetter / ursina / ursina / entity.py View on Github external
def shake(self, duration=.2, magnitude=1, speed=.05, direction=(1,1)):
        import random
        s = Sequence()
        original_position = self.position
        for i in range(int(duration / speed)):
            s.append(Func(self.set_position,
                Vec3(
                    original_position[0] + (random.uniform(-.1, .1) * magnitude * direction[0]),
                    original_position[1] + (random.uniform(-.1, .1) * magnitude * direction[1]),
                    original_position[2],
                )))
            s.append(Wait(speed))
            s.append(Func(self.set_position, original_position))

        s.start()
        return s
github pokepetter / ursina / ursina / entity.py View on Github external
def animate(self, name, value, duration=.1, delay=0, curve=curve.in_expo, resolution=None, interrupt=True, time_step=None):
        s = Sequence(
            Wait(delay),
            Func(self._animate, name, value, duration, curve, resolution, interrupt, time_step)
        )
        s.start()
        return s
github pokepetter / ursina / ursina / ursinastuff.py View on Github external
def invoke(function, *args, **kwargs):
    delay = 0
    if 'delay' in kwargs:
        delay = kwargs['delay']
        del kwargs['delay']

    if not delay:
        function(*args, **kwargs)
        return function

    s = Sequence(
        Wait(delay),
        Func(function, *args, **kwargs)
    )
    s.start()
    return s
github pokepetter / ursina / ursina / ursinastuff.py View on Github external
def destroy(entity, delay=0):
    if delay == 0:
        _destroy(entity)
        return

    s = Sequence(
        Wait(delay),
        Func(_destroy, entity)
    )
    s.start()
github pokepetter / ursina / ursina / text.py View on Github external
from ursina.ursinastuff import invoke
        self.enabled = True
        # self.visible = True   # setting visible seems to reset the colors
        if self.appear_sequence:
            self.appear_sequence.finish()

        x = 0
        self.appear_sequence = Sequence()
        for i, tn in enumerate(self.text_nodes):
            target_text = tn.node().getText()
            tn.node().setText('')
            new_text = ''

            for j, char in enumerate(target_text):
                new_text += char
                self.appear_sequence.append(Wait(speed))
                self.appear_sequence.append(Func(tn.node().setText, new_text))

        self.appear_sequence.start()
        return self.appear_sequence
github pokepetter / ursina / ursina / sequence.py View on Github external
def generate(self):
        self.funcs = list()

        for arg in self.args:
            if isinstance(arg, Wait):
                self.duration += arg.duration
            elif isinstance(arg, (int, float)):
                self.duration += arg

            elif isinstance(arg, Func):
                arg.delay = self.duration
                self.funcs.append(arg)