53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#include "versatile_sprite.hpp"
|
|
#include "sprite_factory.hpp"
|
|
#include "../texture_config.h"
|
|
|
|
VersatileSprite::VersatileSprite(const std::string &name, sf::Vector2f size)
|
|
{
|
|
// Try to find in sprites
|
|
if (all_sprites.find(name) != all_sprites.end())
|
|
{
|
|
auto spriteObject = SpriteFactory::createSingleSprite(name, size);
|
|
addChild(spriteObject);
|
|
sprite = spriteObject;
|
|
} else if (all_animations.find(name) != all_animations.end())
|
|
{
|
|
auto spriteObject = SpriteFactory::createAnimatedSprite(name, size);
|
|
addChild(spriteObject);
|
|
sprite = spriteObject;
|
|
} else if (all_masked_sprites.find(name) != all_masked_sprites.end())
|
|
{
|
|
auto spriteObject = SpriteFactory::createMaskedSprite(name, size);
|
|
addChild(spriteObject);
|
|
sprite = spriteObject;
|
|
} else
|
|
{
|
|
LOG(ERROR) << "Sprite " << name << " not found. Could not create versatile sprite.";
|
|
return;
|
|
}
|
|
}
|
|
|
|
void VersatileSprite::setSize(const sf::Vector2f &size)
|
|
{
|
|
sprite->setSize(size);
|
|
}
|
|
|
|
sf::Vector2f VersatileSprite::getSize() const
|
|
{
|
|
return sprite->getSize();
|
|
}
|
|
|
|
sf::Sprite VersatileSprite::getSprite() const
|
|
{
|
|
return sprite->getSprite();
|
|
}
|
|
|
|
void VersatileSprite::setRotation(float angle)
|
|
{
|
|
sprite->setRotation(angle);
|
|
}
|
|
|
|
bool VersatileSprite::isVisible() const
|
|
{
|
|
return sprite->isVisible();
|
|
}
|