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 - Teras23

Pages: [1]
1
Window / Re: How to detect a single buttonpress?
« on: November 11, 2012, 04:44:23 pm »
Oh... I was using sfml 2.0 so I only read the 2.0 tutorial and that does not have a lot in it, but thanks.

2
Window / Re: How to detect a single buttonpress?
« on: November 11, 2012, 02:38:20 pm »
#include <SFML\Graphics.hpp>
void Mouse(sf::RenderWindow &App);
int _tmain(int argc, _TCHAR* argv[])
{      
        sf::RenderWindow App(sf::VideoMode(1280, 720),"Testing");

        while(App.isOpen())
        {
                sf::Event Event;
                while(App.pollEvent(Event))
                {
                        switch(Event.type)
                        {
                        case sf::Event::Closed:
                                App.close();
                        }
                }
                App.clear();
                Mouse(App);
                App.display();
        }
        return 0;
}

void Mouse(sf::RenderWindow &App)
{
        sf::Event Event;
        while(App.pollEvent(Event))
        {
                switch(Event.type)
                {
                case sf::Event::KeyPressed:
                        std::cout << "test";
                }
        }

}
 
It does not print out test every time you press a key it does it randomly or if you hold down the key it stats printing it out but not in a fixed pattern.

3
Window / Re: How to detect a single buttonpress?
« on: November 11, 2012, 12:52:08 pm »
So I was messing around with this and I think this is what you mean.
                sf::Event Event;
                while(App.pollEvent(Event))
                {
                        switch(Event.type)
                        {
                        case sf::Event::MouseButtonPressed:
                                        std::cout << "Mouse pressed";
                        }
                }
 
But I had problems with having this outside of the main function. I dont know if this is event supposed to be done outside the main function but when I had this in a function that was called every frame it did not work normally.

4
Window / Re: How to detect a single buttonpress?
« on: November 10, 2012, 10:51:01 pm »
So after looking at the events agand and thinking for another 30 min I finally figured it out.
        bool pressed;
        sf::Event Event;
        if(Event.type == sf::Event::MouseButtonPressed && Event.mouseButton.button == sf::Mouse::Right && !pressed)
        {
            the thing to do here;
                pressed = true;
        }
        if(Event.type == sf::Event::MouseButtonReleased && Event.mouseButton.button == sf::Mouse::Right)
                pressed = false;
but is this the best way of doing it?

5
Window / Re: How to detect a single buttonpress?
« on: November 10, 2012, 10:17:22 pm »
It would have been enough if you had looked at the tutorials. sf::Event is what you need.

I had looked at the tutorials but none of that stuff helped me, because it still checks is the mouse is down every frame and therefor do something every frame.

6
Window / Re: How to detect a single buttonpress?
« on: November 10, 2012, 07:45:54 pm »
Posted this in the wrong place, didn't I :-[ .

7
Window / How to detect a single buttonpress?
« on: November 10, 2012, 07:22:39 pm »
I need to find a way that returns something or changes a value by 1 in a single key/button press, but everything I tried still does it every frame. I know would have to use the pressed and released event but I just cant figure out how. I also searched on the internet for the answer but I did not find anything.

Pages: [1]