/
EugenyCh7
/
Puppet2D.Net
Обзор
Документация
Войти
/
EugenyCh7
/
Puppet2D.Net
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Puppet2D.Engine/Components/Animations/Animation.cs
45 строк
1 KB
EugenyCh7
+ Animation
16 авг 2025, 21:21
16 авг 2025, 21:21
57d5162
Код
Авторство
О чём код?
using Puppet2D.Graphics; using System; using System.Linq; namespace Puppet2D.Engine.Components.Animations { public class Animation { public Texture[] Frames { get; set; } public RepeatType RepeatType { get; set; } /// <summary> /// The duration of the frame. /// </summary> public TimeSpan FrameDuration { get; set; } /// <summary> /// The duration of the track. /// </summary> public TimeSpan TrackDuration { get => Frames.Length * FrameDuration; } public Texture GetFrame(TimeSpan time) { switch (RepeatType) { case RepeatType.Once: { if (time < TrackDuration) return Frames[(int)(time.Ticks / FrameDuration.Ticks) % Frames.Length]; else return Frames.Last(); } case RepeatType.Loop: { return Frames[(int)(time.Ticks / FrameDuration.Ticks) % Frames.Length]; } default: throw new NotImplementedException(); } } } }