I am maing a small game using SFML, anyway, my issue is that when rendering the sprite, and moving with float values. The sprite has a white background that 1 pixel one whichever side is moving gets shown.
Here is my Spritesheet class:
Spritesheet::Spritesheet(std::string t) {
this->texture.loadFromFile(t);
this->sprite.setTexture(this->texture);
}
sf::Sprite Spritesheet::getSprite(int x, int y, int width, int height) {
sf::Sprite spt;
spt.setTexture(this->texture);
spt.setTextureRect(sf::IntRect(x, y, width, height));
return spt;
}
void Spritesheet::setSprite(std::string t) {
this->texture.loadFromFile(t);
this->sprite.setTexture(this->texture);
}
And then the player class which is the class that draws the sprite:
Player::Player(int x, int y) {
// Some other code
this->spritesheet.setSprite("./res/img/tiles.png");
this->sprite = this->spritesheet.getSprite(48, 48, 16, 16);
this->sprite.setPosition(x, y);
this->sprite.scale(4, 4);
}
// Further down
void Player::render(RenderWindow& g) {
g.draw(this->sprite);
}
I have also tried using the sprite function setColor
but that changes the texture color aswell.