So I created a basic pong game in SFML using a single main.cpp file. Now I want to better organize the game so I created a seperate class to handle loading in the sprites, displaying them and then destroying them. I wanted to keep everything simple so I made sure the loading in file was under Public:
This is a line of code I use to load in a sprite
sf::Texture paddle; if(!paddle.loadFromFile("Paddle.png")) std::cout << "Could not load paddle." << std::endl; sf::Sprite sPaddle; sPaddle.setTexture(paddle);
So in the main program I make a call to that function however when I debug and run the program it says that sPaddle was not declared in this scope. The function was called directly after declaring my variables and initializing the screen. Also the function is in the public section of the class. The line of code that is trying to call sPaddle specifically
sPaddle.setPosition(0, SCREENHEIGHT/2 - (PADDLEHEIGHT/2));
comes directly after. What is wrong?
I never uploaded code before so if you need to look at it just let me know, Thanks