2013-11-04 4 views
1

나는 sfml 2.1로 시작하지만 유동적으로 실행되도록 프로그램을 만드는 방법을 찾을 수 없다.SFML - 유체 화면 업데이트?

나는 프로그램이 작동한다는 것을 의미하지만, 버튼을 누르거나 마우스를 움직이는 것과 같은 일을하지 않는 한, 메인 루프 실행 못해, 여기

내 메인 루프 코드

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

어떤 아이디어에 대한 예입니다?

+0

(http://sfml-dev.org/documentation/2.1/classsf_1_1Window.php#a338e996585faf82e93069858e3b531b7), 코드 [즉,이 일을 해야하는 방법입니다] 그 while (window.pollEvent (event)) 루프 밖에서 "always"를 실행해야한다. – fvu

+0

[튜토리얼] (http://sfml-dev.org/tutorials/2.1/)을 정말로 읽어야합니다. SFML을 사용하려면 필수적입니다. –

+0

예를 들어, 스프라이트를 왼쪽으로 옮기고 싶다면 어떻게해야합니까? – user2953006

답변

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(); 
    } 
+0

나는 코드를 가지고있다. 문제는 화면이 심지어 윈도우즈의 함수 window.display()를 호출하더라도 업데이트되지 않는다는 것이다. – user2953006

+0

@ user2953006 코드를 게시해야합니다. 실제 문제가 무엇인지 알려주지 않으면 도움을 드릴 수 없습니다. – nvoigt

+0

코드 스 니펫으로 여기에 게시하는 데 도움이 필요하면 window.clear()를 호출해야합니다. – Canvas