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


C++ Font::loadFromFile方法代码示例

本文整理汇总了C++中sf::Font::loadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::loadFromFile方法的具体用法?C++ Font::loadFromFile怎么用?C++ Font::loadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sf::Font的用法示例。


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

示例1: window

void * init () 
{
    sf::Clock sclock;
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

    char * font_path;
    find_font( &font_path );

    if (!MyFont.loadFromFile(font_path)) 
    {
        printf("error loading font\n");
    }

    setup();
    draw_hud();

    for (int i = 1; i < 6; i++)
        add_slot(i);

    while (window.isOpen()) 
    {
        update(window, sclock);
    }
    return NULL;
}
开发者ID:dho1,项目名称:Project,代码行数:25,代码来源:hud.cpp

示例2: Initialize

void Scoring::Initialize()
{
	font.loadFromFile("./Resources/Fonts/jokerman.ttf");
	points_graphics.setFont(font);
	points_graphics.setCharacterSize(24);
	points_graphics.setString("0");
}
开发者ID:vsrz,项目名称:VHH,代码行数:7,代码来源:scoring.cpp

示例3: gameWindow

	Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
	{
		ball.setFillColor(sf::Color::Cyan);
		ball.setPosition(100.0, 100.0);
		ball.setRadius(10.f);

		p1Paddle.setFillColor(sf::Color::Green);
		p1Paddle.setPosition(10.0, 100.0);
		p1Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p2Paddle.setFillColor(sf::Color::Red);
		p2Paddle.setPosition(580.0, 100.0);
		p2Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p1MovingUp = false;
		p1MovingDown = false;
		p2MovingUp = false;
		p2MovingDown = false;

		ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
		font.loadFromFile("arial.ttf");

		p1ScoreText.setPosition(150, 10);
		p1ScoreText.setFont(font);
		p1ScoreText.setString(std::to_string(p1Score));
		p1ScoreText.setColor(sf::Color::Red);
		p1ScoreText.setCharacterSize(24);

		p2ScoreText.setPosition(450, 10);
		p2ScoreText.setFont(font);
		p2ScoreText.setString(std::to_string(p2Score));
		p2ScoreText.setColor(sf::Color::Red);
		p2ScoreText.setCharacterSize(24);
	}
开发者ID:minhoolee,项目名称:id-Tech-Files,代码行数:34,代码来源:Main.cpp

示例4: init

    void init() {
        this->restart();
        // RectangleShapes
        sf::Vector2f unit(unit_w, unit_h);
        stone_view = sf::RectangleShape(unit);
        stone_view.setFillColor(sf::Color(255, 81, 68));
        body_view = sf::RectangleShape(unit);
        body_view.setFillColor(sf::Color(0, 204, 255));
        food_view = sf::RectangleShape(unit);
        food_view.setFillColor(sf::Color(19, 169, 136));

        // font & msg
        if (!font.loadFromFile("Inconsolata-Bold.ttf")) {
            puts("fonts loading error!");
            this->close();
        }
        msg1.setFont(font);
        msg1.setColor(sf::Color::White);
        msg1.setCharacterSize(50);
        msg1.setPosition(80, 100);
        msg2.setFont(font);
        msg2.setColor(sf::Color::White);
        msg2.setCharacterSize(25);
        msg2.setString("Press <Enter> to Replay");
        msg2.setPosition(60, 250);
    }
开发者ID:amoshyc,项目名称:sfml-snake,代码行数:26,代码来源:main.cpp

示例5: LoadFromFile

  bool FontHandler::LoadFromFile(const typeAssetID theAssetID, sf::Font& theAsset)
  {
    // Start with a return result of false
    bool anResult = false;

    // Retrieve the filename for this asset
    std::string anFilename = GetFilename(theAssetID);

    // Was a valid filename found? then attempt to load the asset from anFilename
    if(anFilename.length() > 0)
    {
      // Load the asset from a file
#if (SFML_VERSION_MAJOR < 2)
      anResult = theAsset.LoadFromFile(anFilename);
#else
      anResult = theAsset.loadFromFile(anFilename);
#endif
    }
    else
    {
      ELOG() << "FontHandler::LoadFromFile(" << theAssetID
        << ") No filename provided!" << std::endl;
    }

    // Return anResult of true if successful, false otherwise
    return anResult;
  }
开发者ID:ItsJackson,项目名称:gqe,代码行数:27,代码来源:FontHandler.cpp

示例6: init

	virtual void init()
	
	
	{
		dt=0;
		select_switch = 0.2;
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
	//	darken = sf::RectangleShape(sf::Vector2f(800,400));
		
//sfx
if (!buffer.loadFromFile("sfx/Blip 007.wav"))

{
     //error
}
blip.setBuffer(buffer);


		if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl;

		tits.setTexture(title);
		tits.setOrigin(50,8);
		tits.setScale(sf::Vector2f(3,3));
		tits.setPosition(400,100);
		
		sf::FloatRect tempt ;
		
		for(int i =0 ; i<4;i++)
		{
			selector[i].setFont(standard_font);
			selector[i].setCharacterSize(28);
			 
		
		// dla centrowania obiektow
		
			tempt = selector[i].getGlobalBounds();
			selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
			
			selector[i].setPosition(350,150+30*i);
		}
		
		selector[0].setString("Start game");
		selector[1].setString("Info");
		selector[2].setString("Highscores");
		selector[3].setString("Exit");
		
		
		selector[0].setColor(sf::Color(0,127,127));
		
		timer.restart();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:56,代码来源:menu.cpp

示例7: initalize

	bool initalize(sf::RenderWindow*& rw){
		//renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1920, 1080, 32), "SFML", sf::Style::Fullscreen);
		renderWindow = rw = new sf::RenderWindow(sf::VideoMode(1280, 720, 32), "NMLB");
		drawCalls = frameCount = 0;

		cameraX = TARGET_WIDTH / 2;
		cameraY = TARGET_HEIGHT / 2;
		cameraZ = 1.0f;

		return menuFont.loadFromFile(c::fontDir.child("Arial.ttf").path());
	}
开发者ID:LEiden94,项目名称:No-Man-Left-Behind,代码行数:11,代码来源:GI.cpp

示例8: load

int WindowCreateThing::load() {
    if(!font.loadFromFile("arial.ttf")){
        std::cerr << "Error loading arial.png" << std::endl;
        return (-1);
    }

    if(!textureFolder.loadFromFile("folder.png")) {
        std::cerr << "Error loading folder.png" << std::endl;
        return (-1);
    }
    return 0;
}
开发者ID:3991,项目名称:Game-25486,代码行数:12,代码来源:WindowCreateThing.hpp

示例9: init

	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 


		tit.setString("Made by");

		explain.setFont(standard_font);
		explain.setString("Just a bored slacker");
		explain.setCharacterSize(36);
		explain.setPosition(260,320);

		tit.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));

		
		tit.setPosition(400,120);


if (!tex.loadFromFile("gfx/jabslogo.png"))
	
	{
		std::cout<<"Fuckup"<<std::endl;
		}

		spr.setTexture(tex);
		spr.setPosition(334,144);

		
		timer.restart();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:52,代码来源:jabs.cpp

示例10: set_font

	void set_font()
	{
		
		assert(m_file_name != "");
		
		if (!m_font.loadFromFile(m_file_name))
		{
				
			std::cout << m_file_name << " not found!\n";
				
		}
		 
	}
开发者ID:janderkkotlarski,项目名称:Gravtacles,代码行数:13,代码来源:Gravtacles_V0-7.cpp

示例11:

	// Constructeur & destructeur
	Observer(const sf::Vector2f& center)
	{
		//sf::Font font;
		assert(_font.loadFromFile("vera.ttf") == true);
		_text.setColor(sf::Color::White);
		_text.setFont(_font);
		_text.setCharacterSize(50);
		_text.setStyle(sf::Text::Italic);
		_border.setPosition(center);
		_border.setOutlineColor(sf::Color::White);
		_border.setOutlineThickness(2.0);
		_border.setFillColor(sf::Color::Transparent);
	}
开发者ID:xeloni,项目名称:ProjetsClion,代码行数:14,代码来源:observer.hpp

示例12: initTexts

void initTexts()
{
    if (!font.loadFromFile("arial.ttf"))cout << "error";
    endText.setFont(font);
    endText.setString("Game Over");
    endText.setCharacterSize(50);
    endText.setColor(sf::Color( 156, 39, 176));
    endText.setPosition(SIZE/2-100,SIZE/2-100);
    scoreText.setFont(font);
    scoreText.setCharacterSize(50);
    scoreText.setColor(sf::Color(255,255,255));
    scoreText.setPosition(SIZE/2-200,SIZE/2);
}
开发者ID:Nineshadow,项目名称:Snake-in-C---and-SFML,代码行数:13,代码来源:snake.cpp

示例13: init

	virtual void init()
	
	
	{
		dt=0;
		
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
		darken = sf::RectangleShape(sf::Vector2f(800,400));
		

		
		tit.setFont(standard_font); 
		score.setFont(standard_font); 

		std::stringstream ss;
		ss << your_score;
		std::string str = ss.str();
		
		
		tit.setString("Congrats! You beat the game\nIt took you:");
		
		score.setString(str + " seconds");


		tit.setCharacterSize(24);
		score.setCharacterSize(24);

		
		// dla centrowania obiektow
		
		sf::FloatRect tempt = tit.getGlobalBounds();
		sf::FloatRect tempr = score.getGlobalBounds();

		
		tit.setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
		score.setOrigin(sf::Vector2f(tempr.width/2,tempr.height/2));

		
		tit.setPosition(400,150);
		score.setPosition(400,200);

		score.setColor(sf::Color(0,127,127));

		
		timer.restart();
		
		};
开发者ID:TarasJan,项目名称:Sleepwalker,代码行数:51,代码来源:wingame.cpp

示例14:

	sf::Font &GetDefaultFont()
	{
		if (init)
		{
			bool success = defFont.loadFromFile(JOUST_FONT);
			if (!success)
			{
				printf("Failed to load font %s\n", JOUST_FONT);
				exit(1);
			}
			init = false;
		}
		return defFont;
	}
开发者ID:LibreGames,项目名称:ostrichriders,代码行数:14,代码来源:defaultfont.cpp

示例15: drawIntro

void Presentation::drawIntro(sf::RenderWindow &window){
     sf::Font ibm;
    sf::Font font;
    if (!ibm.loadFromFile("ibm.ttf")) {
        std::cerr << "Error loading ibm.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textTitleIntro;
    textTitleIntro.setFont(ibm);
    textTitleIntro.setString("HELLO");
    textTitleIntro.setCharacterSize(100);
    textTitleIntro.setColor(sf::Color::White);
    textTitleIntro.setOrigin(textTitleIntro.getLocalBounds().left+textTitleIntro.getLocalBounds().width/2.0f, textTitleIntro.getLocalBounds().top+textTitleIntro.getLocalBounds().height/2.0f);
    textTitleIntro.setPosition(window.getSize().x/2, textTitleIntro.getLocalBounds().height/1.5f);


   window.draw(textTitleIntro);


    TCHAR nameBuf[MAX_COMPUTERNAME_LENGTH + 2];
    DWORD nameBufSize;

    nameBufSize = sizeof nameBuf - 1;
    if (GetUserName(nameBuf, &nameBufSize) == TRUE) {
    //_tprintf(_T("Your computer name is %s\n"), nameBuf);
    }
    //std::cout << nameBuf << std::endl;
    strcpy (str,"HELLO (C) ");
    strcat (str,nameBuf);

    if (!font.loadFromFile("arial.ttf")) {
        std::cerr << "Error loading arial.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textSubTitleIntro;
    textSubTitleIntro.setFont(font);
    textSubTitleIntro.setString(str);
    textSubTitleIntro.setCharacterSize(25);
    textSubTitleIntro.setColor(sf::Color::White);
    textSubTitleIntro.setPosition(20, window.getSize().y/2);
    window.draw(textSubTitleIntro);

    sf::Text textContinueIntro;
    textContinueIntro.setFont(font);
    textContinueIntro.setString("Space to continue or Esc to cancel");
    textContinueIntro.setCharacterSize(25);
    textContinueIntro.setColor(sf::Color::White);
    textContinueIntro.setPosition(20, window.getSize().y/3);
    window.draw(textContinueIntro);
}
开发者ID:3991,项目名称:Game-25486,代码行数:50,代码来源:Presentation.hpp


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