diff options
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/Animator.cpp | 5 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index d206428..178b165 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -18,7 +18,10 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a animator_rect.h /= col; animator_rect.w /= row; animator_rect.x = 0; - animator_rect.y = (col_animator - 1) * animator_rect.h; + animator_rect.y = col_animator * animator_rect.h; this->active = false; + + // need to do this for to get the aspect ratio for a single clipping in the spritesheet + this->spritesheet.aspect_ratio = (double)animator_rect.w / (double)animator_rect.h; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 66599c9..89f9121 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -68,7 +68,13 @@ public: //! height in world units int height = 0; - const double aspect_ratio; + /** + * \aspect_ratio ratio of the img so that scaling will not become weird + * + * cannot be const because if Animator component is addded then ratio becomes scuffed and + * does it need to be calculated again in the Animator + */ + double aspect_ratio; public: /** @@ -90,7 +96,7 @@ private: friend class AnimatorSystem; //! Render area of the sprite this will also be adjusted by the AnimatorSystem if an Animator - // object is present in GameObject + // object is present in GameObject. this is in sprite pixels Rect sprite_rect; }; |