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

Pages: [1]
1
Window / Re: GetFrameTime() in SFML 2.0
« on: November 04, 2012, 05:02:06 pm »
Thanks.

2
Window / GetFrameTime() in SFML 2.0
« on: November 04, 2012, 04:07:04 pm »
I cannot find getFrameTime() in SFML 2.0 in order to create hardware independent animations without restricting the framerate (Vsync and setFreameRate() included).

What are you guys using?

3
Window / Re: Handling mouse input outside of Window::GetEvent()
« on: October 25, 2012, 07:35:35 pm »
@eXpl0it3r:
Ok, good to know about input handling in v2, but I won't make the switch right now.
And I didn't really get what you meant by getting the object outside the loop and using it inside...

@cire:
Thank you, I did what you suggested!


Marked as solved!

4
Window / [SOLVED] Handling mouse input outside of Window::GetEvent()
« on: October 25, 2012, 04:43:48 pm »
Hi.

I'm trying to create a Player class so I can do Player::GetInput() in the main loop and leave that class worry about mouse, keyboard, joystick or whatever, at the moment Player::GetInput() should somehow handle mouse clicks and return the click's position.

The main loop looks something like:
while(window.IsOpened()){
        while(window.GetEvent(event)){
            if(event.Type == sf::Event::Closed){
                window.Close();
            }
            else if(event.Type == sf::Event::MouseButtonReleased
                    && event.MouseButton.Button == sf::Mouse::Left){
                pos = std::make_pair(event.MouseButton.X, event.MouseButton.Y);
            }
        }

        window.Clear();
        window.Display();
}
 

What I want to do is:
while(window.IsOpened()){
        while(window.GetEvent(event)){
            if(event.Type == sf::Event::Closed){
                window.Close();
            }
        }

        pos = player.GetInput(window); //player is an instance of Player

        window.Clear();
        window.Display();
}
 

But if I move that "else if" part of the window.GetEvent() loop in Player::GetInput() I won't get any input because I already popped everything on the stack in the main loop, thus the stack is empty when calling player.GetInput().

I also tried to use window.GetInput(), Input::IsMouseButtonDown() along with Input::GetMousex(), Input::GetMouseY(), but this isn't a good choice for getting mouse click positions because if I click somewhere the application registers 2-3-4 clicks when in fact I clicked once (I also tried to set window.EnableKeyRepeat(false) but that seems to work just for keyboard).

How should I implement Player.GetInput() so I get mouse click positions outside the main loop and only getting the click position, no more, no less?

Pages: [1]
anything