The fade in and out only works if i put the line with /****/ in. if i take that line out it doesnt work. basically if i take that line out, i have to continuously press the return key (which switches screens) in order to fade in and out. if i put the line in, then i can press the return key once and it will fade out, switch screens, and fade the new screen in. I have read the events tutorial. From what i deduced, if no event is happening it wont even go inside the while(pollEvent()) and it will just keep looping the while(isOpen()) loop. And my update() function is called inside the while(pollEvent()). So i made a call to update outside (the /****/ line). is this a good way to do things?
As I already said if you do it with your strange event/input handling then you have to make sure that the event is filled with the correct values otherwise the behavior is undefined...
i looked at your SmallGameEngine and it seems your using a stack to push and pop states. it seems kind of advanced and i dont quite understand how you fade in your IntroState. You reduce the alpha value everytime it loops irrespective of keypresses. Its really clean code but i havent really used stacks.
Well as I said, the framerate is limited to 60fps thus I can rely on the fact the update function is getting called 60 times every second and thus reducing the alpha value by 1 every iteration will need ~4.25 seconds to go from 255 to 0. I'm drawing a rectangle over the whole screen and simply reduce it's alpha channel until it's fully transparent.
But you're right I don't do anything with keys, it just happens when you start that state until it reaches 0.
How exactly do you use stacks in a game?
It's simply the FILO principle (First In Last Out) and you've got the two operations push() to put a new object onto the stack and pop to remove the top object.
Doesnt while(pollEvent()) push and pop events for you?
Yes it pushes the new events into the queue and pops one event every call and puts it into the referenced event object.
And does C++ only support .hpp headers? i used .h headers for my headers.
C++ (the standard) doesn't really say anything about this, but it's the compilers that define what works and what not and to my knowledge all C++ compiler support the .hpp extention and I advise everyone to use it, when they write C++ code, so you'd already see in what language a library or similar is written in: .c/.h = C; .cpp/.hpp = C++
is there any easy way to center the text in the center of the window? right now im doing this.
You should really read the
documentation...
sf::Text text("Hello", font, 20);
text.setOrigin(text.getGlobalBounds().width/2.f, text.getGlobalBounds().height()/2.f);
text.setPosition(static_cast<sf::Vector2f>(window.getSize()/2.f));
btw how do you change a thread to [SOLVED]?
By editing your first post and changing the title there.
FYI: You really shouldn't be using global variables, that is your singletons are global variables too!