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

Pages: 1 [2]
16
General / Re: sf::Text not declaring properly?
« on: June 20, 2013, 02:31:54 pm »
Your lineone is in the scope of the if condition.

if ( !arial.loadFromFile ( "arial.ttf" ) )
{ }
sf::Text lineone;

that should fix your problem.

17
Graphics / Re: Unexpected Results when using .setOrigin()
« on: June 13, 2013, 01:49:16 am »
sf::Text::getGlobalBounds() has also values for top and left.

So instead of

label.setOrigin(label.getGlobalBounds().width/2, label.getGlobalBounds().height/2);

use

label.setOrigin(
        label.getGlobalBounds().left + label.getGlobalBounds().width/2,
        label.getGlobalBounds().top + label.getGlobalBounds().height/2);

18
Graphics / Re: Unhandled Exception Error with Texture
« on: June 12, 2013, 07:10:50 pm »
Have you tried other images? Some images are corrupted but load fine in (some) image viewers.

19
General / Re: pollEvent problem
« on: May 29, 2013, 01:27:05 am »
You should definitely read the tutorials and the documentation.
Also if you don't provide us your code or a minimal example, it's hard to find out what you are trying to do exactly.  :)

I think you might have something like this:
while (window.isOpen())
{
        sf::Event event;
        while(window.pollEvent(event))
        {
                // ...
        }
       
        // call getKey and do something with it
        int key = getKey(&window);

        // ...
       
        window.clear();
        window.draw(...);
        window.display();
}

The problem with this is, that pollEvent() returns events as long as there are events and the code will only continue if there are no events in queue. So there are no events exept the last one when getKey() is called.

Also, like kralo9 said, you loop until an key is pressed. The window can't draw anything until that happens and seems to be frozen.

You probably want real time input here:
int getKey(sf::RenderWindow* window)
{
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num0))
                return 0;
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num1))
                return 1;
        ...
}
 

Hope that helps.  ;)

Pages: 1 [2]
anything