Added AsloEngine 0.9.0 to Repository
This commit is contained in:
parent
d017dd84b3
commit
881e6c70f2
60 changed files with 2648 additions and 0 deletions
77
asloengine/textobject.cpp
Executable file
77
asloengine/textobject.cpp
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
#include "headers/textobject.hpp"
|
||||
|
||||
namespace asloengine
|
||||
{
|
||||
|
||||
TextObject::TextObject(std::string _name, sf::String _text, sf::Font& _font, uint _text_size)
|
||||
: GameObject(_name)
|
||||
{
|
||||
|
||||
text = std::make_shared<sf::Text>();
|
||||
text->setFont(_font);
|
||||
text->setCharacterSize(_text_size);
|
||||
set_text(_text);
|
||||
|
||||
}
|
||||
|
||||
TextObject::~TextObject() {}
|
||||
|
||||
void TextObject::draw()
|
||||
{
|
||||
|
||||
render_window->draw(*text);
|
||||
|
||||
}
|
||||
|
||||
void TextObject::on_main_property_update()
|
||||
{
|
||||
|
||||
sf::FloatRect text_bounds = text->getLocalBounds();
|
||||
|
||||
text->setOrigin(origin.x * text_bounds.width, origin.y * text_bounds.height * 2);
|
||||
text->setScale(scale);
|
||||
text->setPosition(position);
|
||||
text->setRotation(rotation);
|
||||
|
||||
}
|
||||
|
||||
void TextObject::set_text(sf::String _text)
|
||||
{
|
||||
|
||||
text->setString(_text);
|
||||
|
||||
on_main_property_update();
|
||||
|
||||
}
|
||||
|
||||
void TextObject::set_text_size(uint _text_size)
|
||||
{
|
||||
|
||||
text->setCharacterSize(_text_size);
|
||||
|
||||
on_main_property_update();
|
||||
|
||||
}
|
||||
|
||||
sf::String TextObject::get_text() const
|
||||
{
|
||||
|
||||
return text->getString();
|
||||
|
||||
}
|
||||
|
||||
uint TextObject::get_text_size() const
|
||||
{
|
||||
|
||||
return text->getCharacterSize();
|
||||
|
||||
}
|
||||
|
||||
int TextObject::get_text_length() const
|
||||
{
|
||||
|
||||
return text->getString().getSize();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue