Now beginning on my first project that i actually want to do. And i instantly hit a road block and cant think of solutions because when i try to construct classes i can never get things to be in the "scope" that i want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void Mario::setTexture(){
sf::Texture marioTexture;
if (!marioTexture.loadFromFile("Levels/Mario.png"))
{
}
sf::Sprite marioSprite; // <- declare mariosprite here
marioSprite.setTexture(marioTexture);
}
void Mario::setPosition(int a, int b){
x = a;
y = b;
marioSprite.setPosition(sf::Vector2f(x,y)); // <-- not accessible here
}
marioSprite was not declared in setposition. it was declared in settexture. But i don't know how to make it "declare" it for all of the class. the only solution i can think of is just like my usual solution. write noob code that's no class at all.