本文整理汇总了C++中screen::setRun方法的典型用法代码示例。如果您正苦于以下问题:C++ screen::setRun方法的具体用法?C++ screen::setRun怎么用?C++ screen::setRun使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screen
的用法示例。
在下文中一共展示了screen::setRun方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventsAfterWin
void eventsAfterWin(sf::Event &event, sf::RenderWindow &window, bool &in_menu, int x1, int y1, int x2, int y2)
{
switch(event.type)
{
case sf::Event::MouseButtonPressed:
{
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
sf::Vector2i mPos = sf::Mouse::getPosition(window);
if ( mPos.x >= x1 && mPos.x <= 500 && mPos.y >= y1 && mPos.y <= y1 + 100 )
{
scrn.setRun(true);
in_menu = true;
}
if ( mPos.x >= x2 && mPos.x <= 500 && mPos.y >= y2 && mPos.y <= y2 + 100)
{
window.close();
}
}
}
}
}
示例2: eventsAfterLosing
void eventsAfterLosing(sf::Event &event, sf::RenderWindow &window, bool &in_menu)
{
switch(event.type)
{
case sf::Event::MouseButtonPressed:
{
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
sf::Vector2i mPos = sf::Mouse::getPosition(window);
if ( mPos.x >= 100 && mPos.x <= 200 && mPos.y >= 250 && mPos.y <= 350 )
{
scrn.setRun(true);
in_menu = true;
}
if ( mPos.x >= 250 && mPos.x <= 350 && mPos.y >= 250 && mPos.y <= 300 )
{
window.close();
}
}
}
}
}
示例3: main
//.........这里部分代码省略.........
{
i->motion(scrn, Main);
}
sf::Time elapsed1 = clock.restart();
}
for (list<enemy>::iterator i = enemies.begin(); i != enemies.end(); ++i)
{
sprEnemy.setPosition(sf::Vector2f(i->l, i->b));
window.draw(sprEnemy);
}
}
if ( !bombs.empty())
{
for (list<bomb>::iterator i = bombs.begin(); i != bombs.end(); ++i)
{
sprBomb.setPosition(sf::Vector2f(i->l, i->b));
if ( (i->clock).getElapsedTime().asSeconds() >= 3.0)
{
i->damage(window, sprFire);
if ( (i->clock).getElapsedTime().asSeconds() > 5.0)
{
lst_iter.push_back(i);
}
}
window.draw(sprBomb);
}
}
sprMainHero.setPosition (sf::Vector2f (Main.l, Main.b));
window.draw (sprMainHero);
if ( enemies.empty() && Main.b == lvlup.b && Main.r ==lvlup.r)
{
std::cout<<NUM_LVL<<std::endl;
if ( NUM_LVL < max_num_lvls -1)
{
levelUp();
}
else
{
std::cout<<"I'm here"<< std::endl;
scrn.setRun(false);
}
}
}
else
{
bricks.clear();
bombs.clear();
enemies.clear();
scrn.clearScreen();
scrn.setRun(false);
sf::Text txt1, txt2, txt3, txt4;
if ( NUM_LVL >= max_num_lvls - 1)
{
getText(txt1, font, "You Win!!", 100, 50, 72);
window.draw(txt1);
getText(txt2, font, "Back in menu", 100, 150, 72);
window.draw(txt2);
getText(txt3, font, "Exit", 100, 250, 72);
window.draw(txt3);
}
else
{
gamer_lose = true;
getText(txt1, font, "You lose", 100, 50, 72);
window.draw(txt1);
getText(txt2, font, "Try again?", 100, 150, 72);
window.draw(txt2);
getText(txt3, font, "Yes", 100, 250, 72);
window.draw(txt3);
getText(txt4, font, "No", 250, 250, 72);
window.draw(txt4);
}
}
window.display();
if ( bombs.size() != 0)
{
for (list<list<bomb>::iterator>::iterator i = lst_iter.begin(); i != lst_iter.end(); ++i)
{
bombs.remove( *(*i));
}
lst_iter.clear();
}
} //while (window.isOpen())
return 0;
}