本文整理汇总了C++中FontHolder::load方法的典型用法代码示例。如果您正苦于以下问题:C++ FontHolder::load方法的具体用法?C++ FontHolder::load怎么用?C++ FontHolder::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontHolder
的用法示例。
在下文中一共展示了FontHolder::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
srand(static_cast<unsigned>(time(0)));
sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML works!", sf::Style::Default, sf::ContextSettings(0, 0, 16));
window.setFramerateLimit(144);
using namespace pyro;
using namespace utils;
enum class FontType { Basic };
FontHolder<FontType> fontHolder;
fontHolder.load(FontType::Basic, "C:/Users/glegl/Documents/Visual Studio 2013/Projects/2016 Projects/C++ & SFML Projects/Age of War/Age of War/Assets/Fonts/Menu.ttf");
Text text;
text.activateShadow(true);
text.setFont(fontHolder.get(FontType::Basic));
text.setString("Lorem Ipsum");
text.setCharacterSize(40);
text.setTextColor(sf::Color::Black);
text.setShadowOffset(1.8f, 1.8f);
text.setShadowColor(sf::Color(0, 0, 0, 100));
text.setPosition(0.f, 0.f);
Text text2;
text2.loadFontFromFile("C:/Users/glegl/Documents/Visual Studio 2013/Projects/2016 Projects/C++ & SFML Projects/Age of War/Age of War/Assets/Fonts/Menu.ttf");
text2.setString("Lorem Ipsum");
text2.setCharacterSize(40);
text2.setTextColor(sf::Color::Black);
text2.setPosition(0.f, 100.f);
Text text3;
text3.activateShadow(true);
text3.loadFontFromFile("C:/Users/glegl/Documents/Visual Studio 2013/Projects/2016 Projects/C++ & SFML Projects/Age of War/Age of War/Assets/Fonts/Menu.ttf");
text3.setString("Lorem Ipsum");
text3.setCharacterSize(40);
text3.setTextColor(sf::Color::Black);
text3.setShadowOffset(2.f, 2.f);
text3.setShadowColor(sf::Color(102, 153, 153, 150));
text3.setPosition(0.f, 200.f);
sf::Texture ianTexture;
ianTexture.loadFromFile("C:/Users/glegl/Pictures/Ian/Ian1.jpg");
ParticleSystem particleSystem(sf::Quads, 5000);
particleSystem.activateEmitter(true);
particleSystem.setInitializer([]()
{
Particle particle;
particle.size = sf::Vector2f(2.f, 3.5f);
float speed = 350.f;
float min = -135.f, max = -45.f;
float angle = pyro::math::toRadians(std::rand() / (RAND_MAX / (max - min)) + min);
particle.velocity = sf::Vector2f(cos(angle) * speed, sin(angle) * speed);
particle.acceleration = sf::Vector2f(0.f, 5.f);
int randValue = rand() % 11;
particle.color = sf::Color(std::min(randValue * 25, 255), std::min(randValue * 10, 255) + 153, 255);
particle.lifetime = sf::seconds(2.5f);
return std::move(particle);
});
particleSystem.setAffector([](Particle& particle, sf::Time dt)
{
particle.velocity += particle.acceleration;
particle.position += particle.velocity * dt.asSeconds();
});
sf::Clock clock;
const sf::Time TimePerFrame(sf::seconds(1.f / 60.f));
sf::Time TimeSinceLastUpdate(sf::Time::Zero);
while (window.isOpen())
{
TimeSinceLastUpdate += clock.restart();
while (TimeSinceLastUpdate > TimePerFrame)
{
TimeSinceLastUpdate -= TimePerFrame;
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
particleSystem.setEmitterPosition(static_cast<sf::Vector2f>(sf::Mouse::getPosition(window)));
particleSystem.update(TimePerFrame);
}
window.clear(sf::Color::Black);
window.draw(text);
window.draw(text2);
window.draw(text3);
window.draw(particleSystem);
window.display();
}
return 0;
}