Added AsloEngine 0.9.0 to Repository

This commit is contained in:
Aslan2142 2019-08-29 18:42:28 +02:00
parent d017dd84b3
commit 881e6c70f2
60 changed files with 2648 additions and 0 deletions

49
asloengine/builtin/button.cpp Executable file
View file

@ -0,0 +1,49 @@
#include "headers/button.hpp"
namespace asloengine
{
Button::Button(sf::String _name, sf::String _text, sf::Font& _font, sf::Texture& _texture, uint _text_size)
: text_vertical_offset(3.5), TextOnlyButton(_name, _text, _font, _text_size), SpriteObject(_name, _texture), GameObject(_name) {}
Button::~Button() {}
void Button::draw()
{
SpriteObject::draw();
TextOnlyButton::draw();
}
void Button::on_main_property_update()
{
SpriteObject::on_main_property_update();
sf::FloatRect sprite_bounds = sprite.getLocalBounds();
sf::FloatRect text_bounds = text->getLocalBounds();
sf::Vector2f offset(0, -text_bounds.height / text_vertical_offset);
sf::Vector2f position_correction = calculate_child_position_centered(
sprite_bounds, text_bounds, offset, scale, rotation
);
text->setPosition(position.x + position_correction.x, position.y + position_correction.y);
text->setScale(scale);
text->setOrigin(origin);
text->setRotation(rotation);
sprite_bounds = sprite.getGlobalBounds();
update_clickable(sprite_bounds);
}
void Button::on_start()
{
set_clickable(sprite.getGlobalBounds(), render_window);
}
}