1

私はsfml 2.1から始めていますが、プログラムを流動的に実行する方法を見つけることができません

つまり、プログラムは機能していますが、ボタンを押すかマウスを動かすなど、何かをしない限り、メインループは実行されません。

ここに私のメインループコードの例があります

     window.setFramerateLimit(30);  // set max fps to 30

     while (window.isOpen())
     {
      // this code ignores the framerate limit and doesnt runs when an event is found
         while (window.pollEvent(event))
         {
              // this code works fine but it wont run unless the user presses a key or moves the mouse
         }
     }

何か案は?

4

1 に答える 1

0

メインループは実行されますが、その中で何もしていません。

2.1 のチュートリアルから:

    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        // window.draw(...);

        // end the current frame
        window.display();
    }
于 2013-11-04T15:45:53.780 に答える