本文整理汇总了C++中TextButton::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TextButton::setSize方法的具体用法?C++ TextButton::setSize怎么用?C++ TextButton::setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextButton
的用法示例。
在下文中一共展示了TextButton::setSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void PauseState::init()
{
sf::Vector2f window( mGame->getTarget()->getSize().x, mGame->getTarget()->getSize().y );
sf::Vector2f boxSize( 500.0f, 230.f );
sf::Vector2f boxPosition( window.x / 2.f - boxSize.x / 2.f, window.y / 2.f - boxSize.y / 2.f );
TextButton* bg = new TextButton();
bg->setSize( boxSize );
bg->setPosition( boxPosition );
bg->setBackgroundColor( sf::Color::Black );
bg->setVisible( true );
mMenu.addItem( "1_BG", bg );
TextButton* resume = new TextButton();
resume->setFont( DEFAULT_FONT );
resume->setText( "Resume" );
resume->setTextColor( sf::Color::White );
resume->setHighlightTextColor( sf::Color::Green );
resume->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 20.f ) );
resume->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
resume->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
resume->setVisible( true );
resume->setClickFunction( []( Menu* menu, Game* game )
{
game->popState();
} );
mMenu.addItem( "2_Resume", resume );
// TextButton* restart = new TextButton();
// restart->setFont( DEFAULT_FONT );
// restart->setText( "Restart" );
// restart->setTextColor( sf::Color::White );
// restart->setHighlightTextColor( sf::Color::Green );
// restart->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 90.f ) );
// restart->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
// restart->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
// restart->setVisible( true );
// std::string map = mMap;
// restart->setClickFunction( [map]( Menu* menu, Game* game )
// {
// std::cout << map << std::endl;
// game->popState();
// game->popState();
// game->pushState( new PlayState( map ) );
// } );
// mMenu.addItem( "3_Restart", restart );
TextButton* menu = new TextButton();
menu->setFont( DEFAULT_FONT );
menu->setText( "Return to menu" );
menu->setTextColor( sf::Color::White );
menu->setHighlightTextColor( sf::Color::Green );
menu->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 90.f ) );
menu->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
menu->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
menu->setVisible( true );
menu->setClickFunction( []( Menu* menu, Game* game )
{
game->popState();
game->popState();
} );
mMenu.addItem( "4_Menu", menu );
TextButton* quit = new TextButton();
quit->setFont( DEFAULT_FONT );
quit->setText( "Quit" );
quit->setTextColor( sf::Color::White );
quit->setHighlightTextColor( sf::Color::Green );
quit->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 160.f ) );
quit->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
quit->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
quit->setVisible( true );
quit->setClickFunction( []( Menu* menu, Game* game )
{
game->quit();
} );
mMenu.addItem( "5_Quit", quit );
}