示例#1
0
// Load the resources for the scene from a resource loader
void MainMenu::load(const ResourceLoader& resourceLoader)
{
	Color normalColor(100, 100, 0), selectedColor(255, 255, 0);
	Font menuFont = resourceLoader.loadFont("mainMenu.ttf", 42);
	
	Game* game = getGame();

	_mainMenu.addElement(
		menuFont,
		"Play",
		normalColor,
		selectedColor);

	_mainMenu.addElement(
		menuFont,
		"Settings",
		normalColor,
		selectedColor);

	_mainMenu.addElement(
		menuFont,
		"Quit",
		normalColor,
		selectedColor,
		[&game](){
			game->quit();
		});
}
PlayGraphics::PlayGraphics(sf::RenderWindow& window)
	:m_window(window)
{
	m_button.setSize(sf::Vector2f(BUTTON_WIDTH, BUTTON_HEIGHT));
	m_button.setOutlineColor(sf::Color::Black);
	m_button.setFillColor(sf::Color::Transparent);
	m_button.setOutlineThickness(5);

	ResourceLoader resourceLoader;
	resourceLoader.loadFont(m_buttonFont, ResourceLoader::ARCON_FONT);
	m_buttonText.setFont(m_buttonFont);
	m_buttonText.setCharacterSize(20);
}