本文整理汇总了C++中UIManager::setUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ UIManager::setUnits方法的具体用法?C++ UIManager::setUnits怎么用?C++ UIManager::setUnits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIManager
的用法示例。
在下文中一共展示了UIManager::setUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
uM.spawnUnit(turtle, p.playerUnit->x, p.playerUnit->y + 1);
std::cout << p.playerUnit->x + 1 << p.playerUnit->y + 1 << std::endl;
uM.gatherActions();
sf::Clock frameClock;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
if (event.type == sf::Event::MouseButtonPressed)
{
mousex = sf::Mouse::getPosition(window).x;
mousey = sf::Mouse::getPosition(window).y;
}
if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && event.type == sf::Event::MouseMoved)
{
uimanager.x += event.mouseMove.x-mousex;
uimanager.y += event.mouseMove.y-mousey;
mousex = event.mouseMove.x;
mousey = event.mouseMove.y;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::P))
{
uM.gatherActions();
}
if (event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Button::Right)
{
std::cout << "clicked at " << sf::Mouse::getPosition(window).x-uimanager.x << " " << sf::Mouse::getPosition(window).y-uimanager.y << std::endl;
//std::cout << "is accessible: " << lvl.isAccessible(sf::Mouse::getPosition(window).x - uimanager.x, sf::Mouse::getPosition(window).y - uimanager.y) << std::endl;
int xPos = sf::Mouse::getPosition(window).x - uimanager.x;
int yPos = sf::Mouse::getPosition(window).y - uimanager.y;
//std::cout << lvl.map[xPos / 128][yPos / 128].pawn << std::endl;
if (lvl.isAccessible(xPos, yPos)) {
uM.interact(xPos/128, yPos/128, &p);
std::cout << xPos/128 << yPos/128 << std::endl;
std::cout << "great success !" << std::endl;
} else
std::cout << "no" << std::endl;
}
/* Zooming - Experimental
if (event.type == sf::Event::MouseWheelScrolled)
{
uimanager.scale = signbit(event.mouseWheelScroll.delta)?uimanager.scale*0.95:uimanager.scale*1.05;
}*/
}
//UI Movement
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
uimanager.y += 1;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
uimanager.y -= 1;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
uimanager.x += 1;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
uimanager.x -= 1;
if (sf::Mouse::getPosition(window).x < 20)
uimanager.x += 1;
if (sf::Mouse::getPosition(window).x > 1900)
uimanager.x -= 1;
if (sf::Mouse::getPosition(window).y < 20)
uimanager.y += 1;
if (sf::Mouse::getPosition(window).y > 1060)
uimanager.y -= 1;
// lvl.genDrawable(&output);
// UIManager uimanager;
// uimanager.setTerrain(output);
sf::Time frameTime = frameClock.restart();
animatedShibe.update(frameTime);
window.clear();
//sf::Sprite output2;
//lvl.drawUnits(&output);
//uimanager.setUnits(output2);
//window.draw(*(uimanager.getUI()));
//window.draw(*(uimanager.getUnits()));
uimanager.setUnits(uM.getUnits());
uimanager.drawEverything(&window);
window.draw(animatedShibe);
//window.draw(*sprite);
//window.draw(output);
/*sf::Texture texture;
texture.loadFromFile("Sprites\\PlayerChar.png");
texture.setSmooth(true);
sf::Sprite* sprite = (new sf::Sprite(texture));
(*sprite).setColor(sf::Color(128, 128, 128));
sprite.setTexture(texture);*/
//window.draw(*sprite);
//std::cout << "Current player AP: " << p.playerUnit->currAP << ". Max player AP: " << p.playerUnit->maxAP << "." << std::endl;
window.display();
}
return 0;
}