Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Nedim1

Pages: [1]
1
Feature requests / A button class
« on: November 21, 2013, 11:46:18 pm »
A button class.It would be really helpful.

2
General / How to make a button in SFML?
« on: November 18, 2013, 09:33:03 pm »
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.

Pages: [1]
anything