11#ifndef SFMLSPRITE_HPP_
12#define SFMLSPRITE_HPP_
15#include <SFML/Graphics.hpp>
40 sf::FloatRect rect = _sprite.getGlobalBounds();
41 return {rect.position.x, rect.position.y, rect.size.x, rect.size.y};
45 _sprite.setTextureRect(sf::IntRect{
46 sf::Vector2i{
static_cast<int32_t
>(rect.x),
static_cast<int32_t
>(rect.y)},
47 sf::Vector2i{
static_cast<int32_t
>(rect.w),
static_cast<int32_t
>(rect.h)}});
51 sf::Vector2f pos = _sprite.getPosition();
52 return {
static_cast<double>(pos.x),
static_cast<double>(pos.y)};
55 _sprite.setPosition({
static_cast<float>(position.x),
static_cast<float>(position.y)});
59 return _sprite.getRotation().asDegrees();
64 _sprite.setRotation(sf::radians(angle));
66 _sprite.setRotation(sf::degrees(angle));
70 sf::Vector2f scale = _sprite.getScale();
71 sf::Vector2f size = _sprite.getLocalBounds().size;
72 return {
static_cast<double>(size.x * scale.x),
static_cast<double>(size.y * scale.y)};
76 sf::Vector2f bounds = _sprite.getLocalBounds().size;
77 if (bounds.x == 0 || bounds.y == 0)
return;
79 static_cast<float>(size.x / bounds.x),
80 static_cast<float>(size.y / bounds.y)
Sfml Sprite class - references a SfmlTexture, does not own it. Deleting the sprite never touches the ...
Definition SfmlSprite.hpp:27
void setPosition(Vector2f position) override
Definition SfmlSprite.hpp:54
Rect< float > getBounds() const override
Definition SfmlSprite.hpp:39
~SfmlSprite() override=default
SfmlSprite(SfmlTexture &texture)
Definition SfmlSprite.hpp:30
bool isReady() const override
Definition SfmlSprite.hpp:35
Vector2f getPosition() const override
Definition SfmlSprite.hpp:50
float getRotation() const override
Definition SfmlSprite.hpp:58
void setRotation(float angle, bool isRad=false) override
Definition SfmlSprite.hpp:62
void setSize(Vector2f size) override
Definition SfmlSprite.hpp:75
Vector2f getSize() const override
Definition SfmlSprite.hpp:69
void setCrop(Rect< float > rect) override
Definition SfmlSprite.hpp:44
Sfml Texture class - owns the loaded texture. SfmlSprite only references it (sf::Sprite itself alread...
Definition SfmlTexture.hpp:28
bool isReady() const override
Definition SfmlTexture.hpp:41
Sfml Window class - implements IWindow2 only, sfml has no 3D.
Definition SfmlWindow.hpp:46