Пример #1
0
        public static Tween Create(TweenMode mode, Ease.Easer easer = null, float duration = 1f, bool start = false)
        {
            Tween tween;
            if (cached.Count == 0)
                tween = new Tween();
            else
                tween = cached.Pop();
            tween.OnUpdate = tween.OnComplete = tween.OnStart = null;

            tween.Init(mode, easer, duration, start);
            return tween;
        }
Пример #2
0
 public static Tween Alpha(GraphicsComponent image, float targetAlpha, int duration, Ease.Easer easer, TweenMode tweenMode = TweenMode.Oneshot)
 {
     Entity entity = image.Entity;
     float startAlpha = image.Color.A / 255;
     Tween tween = new Tween(tweenMode, easer, duration, true);
     tween.OnUpdate = (t) => { image.Color.A = (byte)Math.Round(MathHelper.Lerp(startAlpha, targetAlpha, t.Eased) * 255.0f); };
     entity.Add(tween);
     return tween;
 }
Пример #3
0
 public static Tween Scale(GraphicsComponent image, Vector2 targetScale, int duration, Ease.Easer easer, TweenMode tweenMode = TweenMode.Oneshot)
 {
     Vector2 startScale = image.Scale;
     Tween tween = new Tween(tweenMode, easer, duration, true);
     tween.OnUpdate = (t) => { image.Scale = Vector2.Lerp(startScale, targetScale, t.Eased); };
     image.Entity.Add(tween);
     return tween;
 }
Пример #4
0
 public static Tween Set(Entity entity, int duration, Ease.Easer easer, Action<Tween> onUpdate, TweenMode tweenMode = TweenMode.Oneshot)
 {
     Tween tween = new Tween(tweenMode, easer, duration, true);
     tween.OnUpdate += onUpdate;
     entity.Add(tween);
     return tween;
 }
Пример #5
0
 public static Tween Position(Entity entity, Vector2 targetPosition, int duration, Ease.Easer easer, TweenMode tweenMode = TweenMode.Oneshot)
 {
     Vector2 startPosition = entity.Position;
     Tween tween = new Tween(tweenMode, easer, duration, true);
     tween.OnUpdate = (t) => { entity.Position = Vector2.Lerp(startPosition, targetPosition, t.Eased); };
     entity.Add(tween);
     return tween;
 }