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


C++ TextRenderer::SetText方法代码示例

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


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

示例1: CreateScene

void DacSceneFactory::CreateScene(GameManager & manager, GameObject & root)
{
	// Game
	auto gameController = make_shared<GameController>();
	GameObject& bg = root.CreateObject("Background", 0, 0, "BackGround.jpg",gameController );

	// Fuse
	auto fuseController = make_shared<FuseController>();
	fuseController->m_burnTime = TIME_LIMIT;
	fuseController->m_points.push_back(Vector2d(0, 0));
	fuseController->m_points.push_back(Vector2d(-12, -20));
	fuseController->m_points.push_back(Vector2d(-8, -39));
	fuseController->m_points.push_back(Vector2d(-51, -47));
	fuseController->m_points.push_back(Vector2d(-54, -184));
	fuseController->m_points.push_back(Vector2d(-87, -185));

	GameObject& fuse = bg.CreateObject("Fuse", 263, 555, NULL, fuseController);

	// Big Explosion
	auto bigBoomController = make_shared<ParticlesController>();
	bigBoomController->m_controllerLife = -1;
	bigBoomController->m_assetName = "Explosion.png";
	bigBoomController->m_burstSize = 0;
	bigBoomController->m_velocity = 400;
	bigBoomController->m_acceleration = -200;
	bigBoomController->m_life = 3000;
	bigBoomController->m_velocityNoise = 0.8f;
	GameObject& bigBoom = bg.CreateObject("BigBoom", 129, 329, NULL, bigBoomController);
	gameController->m_bigBoom = bigBoomController;


	// Field
	auto fieldController = make_shared<FieldController>();
	fieldController->m_gameController = gameController;
	fieldController->m_fuse = fuseController;
	GameObject& field = bg.CreateObject("Field", 330, 107, NULL, fieldController );
	gameController->m_field = fieldController;

	// Score
	TextRenderer* text = new TextRenderer(manager.GetRenderer());
	text->SetFont(manager.LoadFont("Digital.ttf", 60), { 0xff, 0xff,0xff,0xff });
	text->SetText("000000");
	auto textPtr = shared_ptr<TextRenderer>(text);
	GameObject& score = bg.CreateObject("Score", 20, 50, 180, 70, textPtr, NULL);
	gameController->m_scoreText = textPtr;

	// Timer
	text = new TextRenderer(manager.GetRenderer());
	text->SetFont(manager.LoadFont("Digital.ttf", 70), { 0xff, 0x55,0x00,0xff });
	text->SetText("00");
	auto timerText = shared_ptr<TextRenderer>(text);
	GameObject& timer = bg.CreateObject("Timer", 75, 425, 180, 70, timerText, NULL);
	gameController->m_timerText = timerText;

	// Menu
	SolidRenderer* solid = new SolidRenderer();
	solid->SetColor(0, 0, 0, 220);
	GameObject& menu = root.CreateObject("Menu", 0, 0, manager.SCREEN_WIDTH, manager.SCREEN_HEIGHT,
		shared_ptr<SolidRenderer>(solid),NULL);
	gameController->m_menu = menu.GetSharedPtr();

	// Header text
	text = new TextRenderer(manager.GetRenderer());
	text->SetFont(manager.LoadFont("Digital.ttf", 90), { 0xff, 0xff,0xff,0xff });
	text->SetText("Diamonds&Crystals");
	GameObject& headerText = menu.CreateObject("Header", 20, 30, 0, 0, shared_ptr<TextRenderer>(text), NULL);

	// Sign text
	text = new TextRenderer(manager.GetRenderer());
	text->SetFont(manager.LoadFont("Digital.ttf", 30), { 0xff, 0xff,0xff,0xff });
	text->SetText("by Maxim Machekhin");
	GameObject& signText = menu.CreateObject("Sign", 30, 120, 0, 0, shared_ptr<TextRenderer>(text), NULL);

	// Best score text
	text = new TextRenderer(manager.GetRenderer());
	auto bestScorePtr = shared_ptr<TextRenderer>(text);
	text->SetFont(manager.LoadFont("Digital.ttf", 30), { 0xff, 0xff,0xff,0xff });
	text->SetText("Best score: 000000");
	GameObject& bestScore = menu.CreateObject("BestScore", 120, 230, 0, 0, bestScorePtr, NULL);
	gameController->m_bestScoreText = bestScorePtr;

	// Button
	solid = new SolidRenderer();
	solid->SetColor(0xe0, 0xa0, 0x20, 0xff);
	GameObject& startBtn = menu.CreateObject("StartButton", 280, 400, 200, 100, 
		shared_ptr<SolidRenderer>(solid), make_shared<MouseHoverController>());
	gameController->m_btnStart = startBtn.GetSharedPtr();

	// Button text
	text = new TextRenderer(manager.GetRenderer());
	text->SetFont(manager.LoadFont("Digital.ttf", 90), { 0x00, 0x00,0x00,0xff });
	text->SetText("Start!");
	GameObject& startBtnText = startBtn.CreateObject("StartButtonText", 8, 0, 180, 70, shared_ptr<TextRenderer>(text), NULL);

}
开发者ID:PentagramPro,项目名称:DiamondsAndCrystals,代码行数:95,代码来源:DacSceneFactory.cpp


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