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.


Messages - Nedim1

Pages: [1] 2
1
General / Re: How to make a button in SFML?
« on: December 25, 2013, 08:12:42 pm »
AlexAUT thank you, and this is in SFML version 1,6 right?

2
General / Re: How to make a button in SFML?
« on: December 22, 2013, 01:58:39 pm »
AlexAUT can you please add a link, I can't find the example.Thanks!

3
General / Re: How to make a button in SFML?
« on: December 21, 2013, 10:29:48 pm »
Guys I already made a button, I want to know how to clear the recreated window in the code i posted on this page.That's all.Thanks!

4
General / Re: How to make a button in SFML?
« on: December 20, 2013, 11:34:23 pm »
Wtf so instead of answers i get hate?Thanks a lot guys!!!

5
General / Re: How to make a button in SFML?
« on: December 17, 2013, 02:13:06 pm »
Bump.

6
General / Re: How to make a button in SFML?
« on: December 09, 2013, 10:52:42 pm »
santiaboy thanks for the reply I've written "window.clear(sf::Color::White)" in the code I posted but it doesn't clear it why not?
Also thanks for the tip on the bool thing, this way is faster right?
Thanks!

7
General / Re: How to make a button in SFML?
« on: December 09, 2013, 04:00:12 pm »
K guys so I have another question I'm sure the solution is simple, but now that I have the recreated window how do I clear it here's my code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>


        bool isSpriteHover(sf::FloatRect sprite, sf::Vector2f mp)
        {
                if (sprite.contains(mp)){
                return true;
                }
                return false;
        }


int main()
{      

        sf::RenderWindow window;
                window.create(sf::VideoMode(800, 600),"My first Visual Studio window!");
       
        sf::Texture texture;
        if(!texture.loadFromFile("button1.png"))
        {
                return 1;
        }
       
        sf::Texture backgroundtexture;
        if(!backgroundtexture.loadFromFile("background.png"))
        {
                return 1;
        }
       
        sf::Sprite background;
        background.setTexture(backgroundtexture);
       
        sf::Sprite sprite;
        sprite.setTexture(texture);

        sf::Vector2f mp;
    mp.x = sf::Mouse::getPosition(window).x;
    mp.y = sf::Mouse::getPosition(window).y;

        while(window.isOpen())
        {
                sf::Event event;
               
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();                
               
                        if(isSpriteHover(sprite.getGlobalBounds(), sf::Vector2f(event.mouseButton.x, event.mouseButton.y)) == true)
                        {  
                if(event.type == sf::Event::MouseButtonReleased &&  event.mouseButton.button == sf::Mouse::Left)
                {
                        window.create(sf::VideoMode(400, 200),"The button worked!");
                        window.clear(sf::Color::White);
                        window.display();
                }
                }
       
            }
                window.clear(sf::Color::Black);

                background.setPosition(sf::Vector2f(0, 0));

                window.draw(background);

                sprite.setPosition(sf::Vector2f(50, 300));

                window.draw(sprite);
               
                window.display();

}
       
return 0;
}
 
Thanks!

8
General / Re: How to make a button in SFML?
« on: November 30, 2013, 11:53:02 am »
K so how to make the sprite change when the mouse is over it?
Thanks!

9
General / Re: How to make a button in SFML?
« on: November 26, 2013, 08:20:56 pm »
Lethn you mean the switch statements right?

10
General / Re: How to make a button in SFML?
« on: November 25, 2013, 09:28:52 am »
How about this(I'm not actually creating another window, I'm just recreating the first one).
Here's the code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>


        bool isSpriteHover(sf::FloatRect sprite, sf::Vector2f mp)
        {
                if (sprite.contains(mp)){
                return true;
                }
                return false;
        }


int main()
{      

        sf::RenderWindow window, window2, window3;
                window.create(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);

        sf::Vector2f mp;
    mp.x = sf::Mouse::getPosition(window).x;
    mp.y = sf::Mouse::getPosition(window).y;



        while(window.isOpen())
        {
                sf::Event event;
               
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();                
               
                        if(isSpriteHover(sprite.getGlobalBounds(), sf::Vector2f(event.mouseButton.x, event.mouseButton.y)) == true)
         {
                if(event.type == sf::Event::MouseButtonReleased &&  event.mouseButton.button == sf::Mouse::Left)
                {
                        window.create(sf::VideoMode(400, 200),"The button worked!");
                }
         }
       
             }
                window.clear(sf::Color::Black);

                sprite.setPosition(sf::Vector2f(50, 300));
               
                window.draw(sprite);
               
                window.display();

}
       
return 0;
}
 

11
General / Re: How to make a button in SFML?
« on: November 25, 2013, 09:19:07 am »
Ok I'll work on the first two but what about the third one where should I create it?

12
General / Re: How to make a button in SFML?
« on: November 24, 2013, 11:55:01 pm »
Actually earlier today I made a button if you wanna know the code its:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>


        bool isSpriteHover(sf::FloatRect sprite, sf::Vector2f mp)
        {
                if (sprite.contains(mp)){
                return true;
                }
                return false;
        }


int main()
{      

        sf::RenderWindow window, window2, window3;
                window.create(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);

        sf::Vector2f mp;
    mp.x = sf::Mouse::getPosition(window).x;
    mp.y = sf::Mouse::getPosition(window).y;



        while(window.isOpen())
        {
                sf::Event event;
               
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();                
               
                        if(isSpriteHover(sprite.getGlobalBounds(), sf::Vector2f(event.mouseButton.x, event.mouseButton.y)) == true)
         {
                if(event.type == sf::Event::MouseButtonReleased &&  event.mouseButton.button == sf::Mouse::Left)
                {
                        window.create(sf::VideoMode(400, 200),"The button worked!");
                        while(window.isOpen())
             {
                sf::Event event;
               
                while(window.pollEvent(event))
                   {
                        if(event.type == sf::Event::Closed)
                                window.close();

                        }
              }
                }
         }
       
             }
                window.clear(sf::Color::Black);

                sprite.setPosition(sf::Vector2f(50, 300));
               
                window.draw(sprite);
               
                window.display();

}
       
return 0;
}
 
Now I wanna know if there's a better way to do it.
Thanks!

13
General / Re: How to make a button in SFML?
« on: November 23, 2013, 11:12:30 pm »
So this is my remake:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>


        bool isSpriteHover(sf::FloatRect sprite, sf::Vector2f mp)
        {
                if (sprite.contains(mp)){
                return true;
                }
                return false;
        }


int main()
{      

        sf::RenderWindow window, window2, window3;
                window.create(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);

        sf::Vector2f mp;
    mp.x = sf::Mouse::getPosition(window).x;
    mp.y = sf::Mouse::getPosition(window).y;



        while(window.isOpen())
        {
                sf::Event event;
               
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();                
               
                        if(isSpriteHover) //this should check if the bool is true right?
        {
                if(event.type == sf::Event::MouseButtonReleased &&  event.mouseButton.button == sf::Mouse::Right)
                {
                        sf::Window window;
                        window.create(sf::VideoMode(400, 200),"The button worked!");
                }
       
        }

                        if(sf::Keyboard::isKeyPressed(sf::Keyboard::N))
                        {
                                 window2.create(sf::VideoMode(400, 200),"Another window!");
                        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))
                        {
                                window3.create(sf::VideoMode(500, 300),"The third window!");   
                                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 sort of works now but the problem is no matter where i right click it makes the window I think it has to do with the bool, I think it doesn't check if its true or not, please write how should i check if the bool is true and if I am doing it right why doesn't it work properly?
Thanks!

14
General / Re: How to make a button in SFML?
« on: November 22, 2013, 09:27:52 pm »
K so I was thinking to make a tiny sprite that locks to the mouse coordinates and then to check if it is over the other rectangle, is that a god way?Also should I include Rect.hpp?Any advice is welcome.Thanks!

15
General / Re: How to make a button in SFML?
« on: November 22, 2013, 10:07:43 am »
Well I knew it was only a matter of time before someone would find the cplusplus forum post.Good work G.

Pages: [1] 2
anything