From e72c8d1bbd0d74dcf4a4832d0352f5f8211fc343 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Dec 2022 11:48:06 +0100 Subject: Sprite: add get_size, which returns the texture size and takes into account scaling --- src/graphics/Sprite.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/graphics') diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index b94212e..461b14c 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -34,6 +34,13 @@ namespace mgl { return { sprite.position.x, sprite.position.y }; } + vec2f Sprite::get_size() const { + if(texture) + return get_scale() * mgl::vec2f(texture->get_size().x, texture->get_size().y); + else + return { 0.0f, 0.0f }; + } + void Sprite::set_scale(vec2f scale) { sprite.scale = { scale.x, scale.y }; } -- cgit v1.2.3