当前位置: 首页>>代码示例>>C++>>正文


C++ FontHolder类代码示例

本文整理汇总了C++中FontHolder的典型用法代码示例。如果您正苦于以下问题:C++ FontHolder类的具体用法?C++ FontHolder怎么用?C++ FontHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FontHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: bounds

ScoreNode::ScoreNode(const FontHolder& fonts)
	: mScore()
	, mStaticScoreText()
	, mScoreText()
	, mLivesText()
{
	using namespace utility;

	const auto TextPadding = 5.f;
	mStaticScoreText.setString("Score: ");
	mStaticScoreText.setFont(fonts.get(Fonts::Main));
	mStaticScoreText.setPosition(TextPadding, TextPadding);
	mStaticScoreText.setCharacterSize(30u);

	mScoreText.setString(std::to_string(mScore));
	mScoreText.setFont(fonts.get(Fonts::Main));
	auto bounds(mStaticScoreText.getGlobalBounds());
	mScoreText.setPosition(bounds.left + bounds.width + TextPadding, TextPadding * TextPadding);
	mScoreText.setCharacterSize(25u);
	mScoreText.setColor(sf::Color::Green);
	centerOrigin(mScoreText);

	mLivesText.setString("Lives: ");
	mLivesText.setFont(fonts.get(Fonts::Main));
	const auto XPadding = 600.f;
	mLivesText.setPosition(XPadding, TextPadding);
	mLivesText.setCharacterSize(30u);
}
开发者ID:Clever-Boy,项目名称:Space-Invaders-Clone,代码行数:28,代码来源:ScoreNode.cpp

示例2: mText

TextNode::TextNode(const std::string& text, const FontHolder& fonts) :
    mText(text, fonts.get(Fonts::Main), 20),
    mShow(true)
{
    centerOrigin(mText);
    mText.setColor(sf::Color::White);
}
开发者ID:Lo-X,项目名称:hammer,代码行数:7,代码来源:textnode.cpp

示例3:

TextNode::TextNode(const FontHolder& fonts, const std::string& text)
{
	mText.setFont(fonts.get(Fonts::Main));
	mText.setCharacterSize(20);
	mText.setColor(sf::Color::Black);
	setString(text);
}
开发者ID:ilikeyummycake,项目名称:ducks_are_cool,代码行数:7,代码来源:TextNode.cpp

示例4:

TextNode::TextNode(b2World* _pw, const FontHolder& fonts, const std::string& text)
	:SceneNode(_pw),
	lifetime(0.0)
{
	mText.setFont(fonts.get(Fonts::main));
	mText.setCharacterSize(30);
	mText.setColor(sf::Color::Black);
	setString(text);
}
开发者ID:sanyo678,项目名称:Game_GIT,代码行数:9,代码来源:TextNode.cpp

示例5: mCallback

Button::Button(const FontHolder& fonts, const TextureHolder& textures)
: mCallback()
, mSprite(textures.get(Textures::Buttons))
, mText("", fonts.get(Fonts::Main), 16)
, mIsToggle(false)
{
	changeTexture(Normal);

	sf::FloatRect bounds = mSprite.getLocalBounds();
	mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
}
开发者ID:Codes-With-Eagles-SWE2014,项目名称:Client-Tutorial,代码行数:11,代码来源:Button.cpp

示例6: textureRect

Button::Button(const FontHolder &fonts, const TextureHolder &/*textures*/) :
    mCallback(),
    //mButtonTexture(),
    mSprite(),
    mText("", fonts.get(Fonts::Main), 16),
    mIsToggled(false)
{
    sf::IntRect textureRect(0, 0, 200, 50);
    //mSprite.setTexture(mButtonTexture);
    mSprite.setTextureRect(textureRect);

    sf::FloatRect bounds = mSprite.getLocalBounds();
    mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
}
开发者ID:Lo-X,项目名称:potato-framework,代码行数:14,代码来源:button.cpp

示例7: mCallback

   Button::Button(const FontHolder& fonts, const TextureHolder& textures)
   : mCallback(),
   mNormalTexture(textures.get(Textures::ButtonNormal)),
   mSelectedTexture(textures.get(Textures::ButtonSelected)),
   mPressedTexture(textures.get(Textures::ButtonPressed)),
   mSprite(),
   mText("", fonts.get(Fonts::Main), 16),
   mIsToggle(false) {

      mSprite.setTexture(mNormalTexture);
      centerOrigin(mSprite);

      mText.setPosition(0, 0);
   }
开发者ID:jordandavidson,项目名称:crows_engine,代码行数:14,代码来源:button.cpp

示例8: RectangleShape

    Button::Button(ButtonStyle style, const FontHolder& fonts, const TextureHolder& textures)
    : mStyle(style),
      mFonts(fonts),
      mTextures(textures),
      mIsFocusable(true),
      mIsFixedSize(true),
      mCallback(),
      p_mShape(nullptr),
      p_mSprite(nullptr),
      p_mText(nullptr),
      mColor(COLOR_ON_RELEASED),
      mTextColor(TEXT_COLOR_DEFAULT),
      mScale(1.f, 1.f),
      mState(State::OnReleased)
    {
        if (mStyle == Button::Sprite)
        {
            std::unique_ptr<sf::Sprite> p_sprite(new sf::Sprite());
            p_sprite->setTexture(textures.get(Textures::Button));
            Graphics::centerOrigin(*p_sprite);
            p_mSprite = std::move(p_sprite);
            setText("");
        }
        else
        {
            std::unique_ptr<sf::RectangleShape> p_rect(
                new sf::RectangleShape(sf::Vector2f(BUTTON_WIDTH, BUTTON_HEIGHT)));
            Graphics::centerOrigin(*p_rect);
            p_mShape = std::move(p_rect);

            if (mStyle == ButtonStyle::Text)
            {
                std::unique_ptr<sf::Text> p_text(new sf::Text());
                p_text->setFont(fonts.get(Fonts::Chinese));
                //p_text->setCharacterSize(30);
                p_text->setColor(mTextColor);
                p_text->setString("Button");
                Graphics::centerOrigin(*p_text);
                
                p_mShape->setFillColor(TEXT_BG_COLOR_RELEASED);
                p_mShape->setOutlineThickness(OUT_LINE_THICKNESS);
                p_mShape->setOutlineColor(mTextColor);

                p_mText = std::move(p_text);
            }

            setText("");
        }
    }
开发者ID:eggtart93,项目名称:LuckyDraw,代码行数:49,代码来源:Button.cpp

示例9: SceneNode

WaveGenerator::WaveGenerator(TextureHolder& textures, FontHolder &fonts, MusicPlayer &musics) :
    SceneNode(Category::WaveGenerator),
    mTextures(textures),
    mMusicPlayer(musics),
    mCurrentWaveIndex(-1),
    mCurrentWaveNumber(-1),
    mPoints(0),
    mKidsRemaining(0),
    mWaveState(Paused),
    mWaveTimer(sf::Time::Zero),
    mNbKidPoped(0),
    mGaveTraps(false)
{
    mDisplay.setFont(fonts.get(Fonts::Main));
    mDisplay.setString("0 points - Wave 0");
    centerOrigin(mDisplay);
    mDisplay.setPosition(1280.f / 2 + 150.f, 16.f);

    mWaves = WaveTable;
}
开发者ID:Lo-X,项目名称:ludumdare31,代码行数:20,代码来源:wavegenerator.cpp

示例10: 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;
}
开发者ID:OtemPsych,项目名称:Pyro-Engine,代码行数:96,代码来源:main.cpp

示例11: mText

Label::Label(const std::string& text, const FontHolder& fonts)
: mText(text, fonts.get(Fonts::Arcade), 16)
{
}
开发者ID:login-m,项目名称:game,代码行数:4,代码来源:Label.cpp

示例12: mText

TextNode::TextNode(const std::string& text, const FontHolder& fonts) :
    mText(text, fonts.get(Fonts::Main), 20)
{
    centerOrigin(mText);
}
开发者ID:Lo-X,项目名称:potato-framework,代码行数:5,代码来源:textnode.cpp

示例13: centerOrigin

TextNode::TextNode(const std::string& text, const FontHolder& fontHolder)
    : text_(text, fontHolder.get(FontID::Sensation), 18)
{
    centerOrigin();
}
开发者ID:Skiss,项目名称:space-shooter,代码行数:5,代码来源:TextNode.cpp

示例14:

TextNode::TextNode(const FontHolder& fonts, const std::string& text)
{
	m_text.setFont(fonts.Get(Fonts::Main));
	m_text.setCharacterSize(20);
	SetString(text);
}
开发者ID:Donald522,项目名称:pixels,代码行数:6,代码来源:TextNode.cpp

示例15: setString

TextNode::TextNode(const FontHolder& fonts, const std::string& text, unsigned int size)
{
    mText.setFont(fonts.getConst(Fonts::Main));
    mText.setCharacterSize(size);
    setString(text);
}
开发者ID:martin-mh,项目名称:Redhead-against-rabbits,代码行数:6,代码来源:textnode.cpp


注:本文中的FontHolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。