You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/src/impl/sfml/spritesfml.cpp

34 lines
821 B
C++

#include "spritesfml.h"
SpriteSFML::SpriteSFML(sf::RenderTarget * const render_target,
const std::shared_ptr<sf::Texture>& texture,
const kku::Area<unsigned int> &cropping) :
_render_target(render_target),
_sprite(*texture, sf::IntRect(cropping.left, cropping.top, cropping.width, cropping.height))
{}
void SpriteSFML::setPosition(const kku::Point& position)
{
_sprite.setPosition(position.x, position.y);
}
kku::Point SpriteSFML::getPosition() const
{
const auto& position = _sprite.getPosition();
return kku::Point
{
position.x,
position.y
};
}
void SpriteSFML::move(const kku::Vector2<float>& delta)
{
_sprite.move({delta.first, delta.second});
}
void SpriteSFML::display() const
{
_render_target->draw(_sprite);
}