le2d v0.4.3
2D game engine framework
 
Loading...
Searching...
No Matches
animation.hpp
Go to the documentation of this file.
1#pragma once
5#include <le2d/transform.hpp>
6#include <algorithm>
7
8namespace le {
9namespace anim {
11template <typename PayloadT>
12class Animation : public IAsset {
13 public:
14 using Payload = PayloadT;
15
16 [[nodiscard]] auto get_timeline() const -> Timeline<Payload> const& { return m_timeline; }
17
19 m_timeline = std::move(timeline);
20 std::ranges::sort(m_timeline.keyframes, [](Keyframe<Payload> const& a, Keyframe<Payload> const& b) { return a.timestamp < b.timestamp; });
21 }
22
23 [[nodiscard]] auto is_loaded() const -> bool { return !m_timeline.keyframes.empty(); }
24
25 std::string name{};
26 bool repeat{true};
27
28 private:
29 Timeline<Payload> m_timeline{};
30};
31} // namespace anim
32
35} // namespace le
Interface for asset types.
Definition asset.hpp:8
Class template for Animation types.
Definition animation.hpp:12
auto is_loaded() const -> bool
Definition animation.hpp:23
void set_timeline(Timeline< Payload > timeline)
Definition animation.hpp:18
PayloadT Payload
Definition animation.hpp:14
bool repeat
Definition animation.hpp:26
auto get_timeline() const -> Timeline< Payload > const &
Definition animation.hpp:16
std::string name
Definition animation.hpp:25
Definition animation.hpp:8
Class template for an animation keyframe.
Definition keyframe.hpp:7
Class template for a list of animation keyframes.
Definition timeline.hpp:8
std::vector< Keyframe< PayloadT > > keyframes
Definition timeline.hpp:9