本文整理汇总了C++中sf::RenderWindow::PollEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::PollEvent方法的具体用法?C++ RenderWindow::PollEvent怎么用?C++ RenderWindow::PollEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::PollEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Show
void SplashScreen::Show(sf::RenderWindow & renderWindow)
{
renderWindow.Clear();
renderWindow.Draw(mySprBack);
renderWindow.Display();
sf::Event event;
//on sort pour faire plus vite
while(false)
{
while(renderWindow.PollEvent(event))
{
if(event.Type == sf::Event::KeyPressed
|| event.Type == sf::Event::MouseButtonPressed
|| event.Type == sf::Event::Closed
|| event.Type == sf::Event::JoystickButtonPressed)
{
return;
}
}
}
}
示例2: main
int main()
{
// Create the main rendering window
App.Create(sf::VideoMode(640,480,32), "SFML Graphics");
UIState uistate;
uistate.renderer = &App;
InitEntities();
PhysicsSub physSub(&App, &entitysystem);
RenderingSystem renderSys(&App, &entitysystem);
ControllerSystem controller(&App, &entitysystem);
ProjectileSystem projSys(&App, &entitysystem);
bool inventory = false;
int invX;
int invY;
std::vector<Entity*> players;
entitysystem.getEntities<CompPlayer>(players);
Entity* player = players[0];
// Start game loop
while (App.IsOpen())
{
// Process events
sf::Event Event;
while (App.PollEvent(Event))
{
uistate.uiEvents(Event);
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
if(Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Right)
{
inventory = !inventory;
if(inventory)
invX = sf::Mouse::GetPosition(App).x;
invY = sf::Mouse::GetPosition(App).y;
}
if(Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Left)
makeProjectile();
}
controller.Tick(Clock.GetElapsedTime().AsSeconds());
physSub.Tick(Clock.GetElapsedTime().AsSeconds());
projSys.Tick(Clock.GetElapsedTime().AsSeconds());
// Clear the screen with red color
App.Clear(sf::Color::Black);
uistate.imgui_prepare();
if(widget::button(uistate, GEN_ID, sf::Vector2f(100, 30), sf::Vector2f(520, 10), "button", 24))
entitysystem.deleteEntity(player);
if(inventory)
if(widget::button(uistate, GEN_ID, sf::Vector2f(100, 30), sf::Vector2f(invX, invY), "inventory", 20))
player = makePlayer();
uistate.imgui_finish();
renderSys.Tick(Clock.GetElapsedTime().AsSeconds());
// Display window contents on screen
App.Display();
Clock.Restart();
}
return EXIT_SUCCESS;
}