SFML Issue

Was starting to code Tetris with SFML and I got an error:
'sf::Window::isOpen' : function call missing argument list; use &sf::Window::isOpen' to create a pointer to member
It suggests using $sf::Window::isOpen
Although this works, I want to completely fix the problem so I don't have to deal with it later.

I found some other similar problems on stack overflow, but they were all with classes that the person made. I'm pretty new to C++ and SFML in general so the solutions to their problems looked like gibberish to me. But I did pick up that it had something to do with the libraries and that they needed to be static. I switched to the static library of SFML, but no cigar.


Here's the very unfinished code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include <SFML\Graphics.hpp>;
#include <iostream>;


int main()
{
	sf::RenderWindow window(sf::VideoMode(1000, 1000), "Tetris");
	
	sf::Font gameFont;
	gameFont.loadFromFile("arial.ttf");

	sf::RectangleShape tblock1;
	tblock1.setSize(sf::Vector2f(32, 32));
	tblock1.setPosition(0, 0);

	while (sf::Window::isOpen)
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
			{
				window.close();
			}
		}

		window.clear();

		window.draw(tblock1);

		window.display();
	}

	return 0;
}


Any help is appreciated, thanks.
IsOpen is not a static class function, you need to call
while(window.isOpen())
Edit: Also, static libraries and static class functions are two different concepts, it wouldn't matter if you compiled SFML statically or not, the user code would be the same. The word "static" is really overused

A static class function is one where the function can be called without an instance (object) of the class being needed
Last edited on
Thanks Ganado. The good news is, your solution works and I'm very appreciative of your help. The bad news is now I have tons of linker errors. (About 70.) Thanks for helping and I'll see if I can fix the other stuff on my own.

Thanks

Edit: I fixed the linker errors by switching the libraries back to non-static. I probably just screwed up putting it to static.
Last edited on
Topic archived. No new replies allowed.