I know from debugging that the in function sprite's position data does correctly change but this is not reflected main version of said sprite. This is also despite the fact that both sprites do indeed share the same address.
I have to be missing something.
This tiny bit of code is fairly simple. If you hit the A key the sprite is suppose to move down and right by 10px. But it doesn't. No idea why.
#include <SFML/Graphics.hpp>
class Test
{
public:
Test(sf::Sprite &tempTestSprite)
{
testSprite = tempTestSprite;
}
sf::Sprite testSprite;
void Blah();
};
void Test::Blah()
{
testSprite.setPosition(testSprite.getPosition().x+10, testSprite.getPosition().y+10);
}
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
sf::Texture texture;
if(!texture.loadFromFile("cb.bmp"))
{
return -1;
}
sf::Sprite logo(texture);
Test tester(logo);
while(window.isOpen())
{
// Process events
sf::Event event;
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::KeyPressed:
{
// Close window : exit
if(event.key.code == sf::Keyboard::Escape)
{
window.close();
}
if(event.key.code == sf::Keyboard::A)
{
tester.Blah();
}
}
}
}
window.clear();
window.draw(logo);
window.display();
}
return 0;
}