Beispiel #1
0
    def process(self, world, sets):
        dt = world.dt
        for hb, s, pb in sets:
            if pb.body:
                v = abs(pb.body.velocity.x) + abs(pb.body.velocity.y)
            else:
                v = 0
            if v >= 30:
                hb.settle = False
            else:
                hb.settle = True
            if hb.cur_time < hb.max_time and not hb.settle:
                hb.offset_y = hb.max_offset * smooth_in_out(
                    hb.cur_time / hb.max_time * 1
                )
                hb.cur_time += dt
            else:
                if hb.settle:
                    if hb.offset_y > 0:
                        hb.offset_y -= hb.max_offset * dt * 2
                    else:
                        hb.offset_y = 0
                else:
                    hb.cur_time = 0

            s.sprite.image.anchor_y = 16 - hb.offset_y
Beispiel #2
0
 def process(self, world, sets):
     dt = world.dt
     for anim, *rest in sets:
         if anim.cur_time < anim.max_time and not anim.settle:
             value = smooth_in_out(
                 anim.cur_time / anim.max_time * 1
             )
             anim.owner.sprite.opacity = value * (anim.max_opacity * 255)
             anim.owner.sprite.scale = anim.scale_min + (
                 value * (anim.scale_max - anim.scale_min)
             )
             anim.cur_time += dt
         else:
             anim.cur_time = 0