Ok guys so I'm trying to make a main menu in SFML, and I wrote the code that I think should work but it doesn't
So if anyone could tell me what I'm doing wrong and how to correct it, it would be greatly appreciated.Thanks!
Here's my code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
class BOX
{
public:
int x, y, w, h;
};
class Obj
{
public:
BOX box;
};
bool active(Obj obj, int mx, int my)
{
if(mx > obj.box.x && mx < obj.box.x + obj.box.w && my > obj.box.y && my < obj.box.y + obj.box.h)
{
return true;
}
return false;
}
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600),"My first Visual Studio window!");
sf::Texture texture;
if(!texture.loadFromFile("button1.png"))
{
return 1;
}
sf::Sprite sprite;
sprite.setTexture(texture);
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(active == true && event.MouseButtonReleased == sf::Mouse::Right) //This line Celtic Minstrel
sf::RenderWindow window(sf::VideoMode(400, 200),"The button worked!");
if(sf::Keyboard::isKeyPressed(sf::Keyboard::N))
{
sf::RenderWindow window2(sf::VideoMode(400, 200),"Another window!");
(window2);
while(window2.isOpen())
{
sf::Event event;
while(window2.pollEvent(event))
{
if(sf::Keyboard::isKeyPressed(sf::Keyboard::C))
{
window2.close();
}
}
}
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::B))
{
sf::RenderWindow window3(sf::VideoMode(500, 300),"The third window!");
(window3);
while(window3.isOpen())
{
sf::Event event;
while(window3.pollEvent(event))
if(sf::Keyboard::isKeyPressed(sf::Keyboard::C))
{
window3.close();
}
}
}
}
window.clear(sf::Color::Black);
sprite.setPosition(sf::Vector2f(50, 300));
window.draw(sprite);
window.display();
}
return 0;
}
It tells me Error:operand types are incompatible("bool"(*)(Obj obj, int mx, int my)" and "bool")
P.S. English is not my native language so if I made any mistakes I apologize.