本文整理汇总了C++中LayerManager::update方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerManager::update方法的具体用法?C++ LayerManager::update怎么用?C++ LayerManager::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerManager
的用法示例。
在下文中一共展示了LayerManager::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Element
void Gamestep3::update()
{
int width= window.getSize().x;
int height= window.getSize().y;
int white1size = white1.size();
int white2size = white2.size();
for(unsigned int j=0; j<white1size; j++){
if(white1size>0 && white1.at(j)->getPosition().y>height+128){
white1.erase(white1.begin()+j);
white1size--;
}
}
for(unsigned int j=0; j<white2size; j++){
if(white2size>0 && white2.at(j)->getPosition().y>height+128){
white2.erase(white2.begin()+j);
white2size--;
}
}
//spawn white1
if(frame%30==0){
int r = 0 + (rand() % ((width-128) - 0));
white1.push_back(new Element(Texture("white1.png"),sf::Vector2f(r,0), 0.f));
float srand = (rand()%5)/10.0;
white1[white1.size()-1]->setScale(0.75+(srand),0.75+(srand));
white1l.addElement(white1[white1.size()-1]);
}
//spawn white2
if(frame%50==0){
int r = 0 + (rand() % ((width-128) - 0));
white2.push_back(new Element(Texture("white2.png"),sf::Vector2f(r,0), 0.f));
float srand = (rand()%10)/10.0;
white2[white2.size()-1]->setScale(0.75+(srand),0.75+(srand));
white2l.addElement(white2[white2.size()-1]);
}
//Update white1
for(std::vector<Element*>::iterator i = white1.begin(); i != white1.end(); i++){
(*i)->move(0,2);
}
//Update white2
for(std::vector<Element*>::iterator i = white2.begin(); i != white2.end(); i++){
(*i)->move(0,1);
}
// Gestion du click
bool lbutton = sf::Mouse::isButtonPressed(sf::Mouse::Left);
bool rbutton = sf::Mouse::isButtonPressed(sf::Mouse::Right);
if( (lbutton || rbutton) && !clicked)
{
clicked = true;
bool clicDansLeVide = true;
for(std::vector<Cell*>::iterator i = cells.begin(); i != cells.end(); i++)
{
if( (*i)->isInside(sf::Mouse::getPosition()) )
{
onclick(*i, lbutton);
clicDansLeVide = false;
break;
}
}
if(lbutton && clicDansLeVide) unselect();
}
if(!lbutton && !rbutton) clicked = false;
// Dessin du réticule pour la cellule selectionnée
if(selectedCell != NULL)
{
reticule.setColor(sf::Color::Green);
reticule.setPosition(selectedCell->getPosition());
reticule.rotate(2);
float scale = (100+abs(((frame/4)%40)-20)) / 100.f;
reticule.setScale( scale * selectedCell->getScale() * 5.f );
}
else
{
reticule.setColor(sf::Color::Transparent);
}
// Suppression des agents inactifs
for(std::vector<Agent*>::iterator i = agents.begin(); i != agents.end();)
{
if( !(*i)->isAlive() )
{
//.........这里部分代码省略.........