diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 14:52:25 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 14:52:25 +0100 |
commit | 0b9574bdd6c5968c07bcf165d66032b75649b5da (patch) | |
tree | 6c16263db778a79c8aaa13bb84bd53c76eaaa9cd /src/crepe | |
parent | 91366375a7b2a9be670e4842604512254a9c116e (diff) | |
parent | b92b3b830dc53ecc2accf8472a8e4ce8be2e19dc (diff) |
Merge branch 'loek/replay' of github.com:lonkaars/crepe
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/api/Sprite.cpp | 13 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 10 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 0107c7b..3c77e2e 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -19,3 +19,16 @@ Sprite::Sprite(game_object_id_t id, const Asset & texture, const Sprite::Data & } Sprite::~Sprite() { dbg_trace(); } + +unique_ptr<Component> Sprite::save() const { return unique_ptr<Component>(new Sprite(*this)); } + +void Sprite::restore(const Component & snapshot) { + *this = static_cast<const Sprite &>(snapshot); +} + +Sprite & Sprite::operator=(const Sprite & snapshot) { + this->active = snapshot.active; + this->data = snapshot.data; + this->mask = snapshot.mask; + return *this; +} diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index a3fc319..3565bed 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -42,10 +42,10 @@ public: FlipSettings flip; //! Layer sorting level of the sprite - const int sorting_in_layer = 0; + int sorting_in_layer = 0; //! Order within the sorting layer - const int order_in_layer = 0; + int order_in_layer = 0; /** * \brief width and height of the sprite in game units @@ -119,6 +119,12 @@ private: //! Render area of the sprite this will also be adjusted by the AnimatorSystem if an Animator // object is present in GameObject. this is in sprite pixels Rect mask; + +protected: + virtual std::unique_ptr<Component> save() const; + Sprite(const Sprite &) = default; + virtual void restore(const Component & snapshot); + virtual Sprite & operator=(const Sprite &); }; } // namespace crepe |