diff options
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/Animator.cpp | 2 | ||||
-rw-r--r-- | src/crepe/api/Animator.h | 11 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 9 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 4c72cc0..123f0e7 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -19,6 +19,8 @@ Animator::Animator(game_object_id_t id, Sprite & spritesheet, const ivec2 & sing this->spritesheet.mask.h = single_frame_size.y; this->spritesheet.mask.x = 0; this->spritesheet.mask.y = 0; + + this->spritesheet.aspect_ratio = static_cast<float>(single_frame_size.x) / single_frame_size.y; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 9a26bf0..09f0134 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -75,8 +75,9 @@ public: * * \param id The unique identifier for the component, typically assigned automatically. * \param spritesheet the reference to the spritesheet - * \param max_row maximum of rows inside the given spritesheet - * \param max_col maximum of columns inside the given spritesheet + * \param single_frame_size the width and height in pixels of a single frame inside the + * spritesheet + * \param max_cell_size the max rows and columns inside the given spritesheet * \param data extra animation data for more control * * This constructor sets up the Animator with the given parameters, and initializes the @@ -87,15 +88,15 @@ public: ~Animator(); // dbg_trace public: - //! The maximum number of rows and columns size - const uvec2 max_cell_size; - Animator::Data data; private: //! A reference to the Sprite sheet containing. Sprite & spritesheet; + //! The maximum number of rows and columns size + const uvec2 max_cell_size; + //! Uses the spritesheet friend AnimatorSystem; }; diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 7e9812d..14a873b 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -92,6 +92,15 @@ private: //! Reads the all the variables plus the mask friend class AnimatorSystem; + + /** + * \aspect_ratio the ratio of the sprite image + * + * - this value will only be set by the \c Animator component for the ratio of the Animation + * - if \c Animator component is not added it will not use this ratio (because 0) and will use aspect_ratio of the Asset. + */ + float aspect_ratio = 0; + struct Rect { int w = 0; int h = 0; |