• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ requestStackPush函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: requestStackPush

bool GameState::handleEvent(const sf::Event& event)
{
	// Game input handling
	CommandQueue& commands = mWorld.getCommandQueue();
	mPlayer.handleEvent(event, commands);

	// Escape pressed, trigger the pause screen
	if (event.type == sf::Event::KeyPressed && 
		event.key.code == sf::Keyboard::Escape)
	{
		requestStackPush(States::Pause);
	}

	// F3 is pressed, so bring up the debug overlay
	else if (event.type == sf::Event::KeyPressed && 
		event.key.code == sf::Keyboard::F3)
	{
		if (mDebugOverlay == false)
		{
			requestStackPush(States::Debug);
			mDebugOverlay = true;
		}
		else
		{
			requestStackPop();
			mDebugOverlay = false;
		}
	}

		

	return true;
}
开发者ID:vsrz,项目名称:sfml-tutorial,代码行数:33,代码来源:GameState.cpp


示例2: switch

 void GameState::onNotify(std::shared_ptr<baseEvent> e){
     switch(e->getType()){
         case EventType::LEVEL_COMPLETE:{
             if(currentLevel<(totalLevels-1)){
                 ++currentLevel;
                 eventQueue = level->getEventQueue(currentLevel);
                 gameEventDispatcher = level->getGameEventDispatcher(currentLevel);
                 gameEventDispatcher->LevelComplete.addObserver(this);
                 gameEventDispatcher->LevelFailed.addObserver(this);
                 gameEventDispatcher->UpdateScore.addObserver(this);
             }else if(currentLevel == (totalLevels-1)){
                 requestStackPush(AppStates::GameSucceed);
             }
         }
             break;
         case EventType::LEVEL_FAILED:{
             requestStackPush(AppStates::GameFailed);
         }
             break;
         case EventType::UPDATE_SCORE:{
             score += std::get<0>(e->getAttributes<EventsAlias::update_score>());
             textScore.setString(Utils::toString(score));
         }
             break;
         default:
             break;
     }
 }
开发者ID:cristianglezm,项目名称:AntFarm,代码行数:28,代码来源:GameState.cpp


示例3: State

MenuState::MenuState(StateStack& stack, Context context)
: State(stack, context)
, mGUIContainer()
{
	sf::Texture& texture = context.textures->get(Textures::TitleScreen);
	mBackgroundSprite.setTexture(texture);

	auto playButton = std::make_shared<GUI::Button>(context);
	playButton->setPosition(100, 300);
	playButton->setText("Play");
	playButton->setCallback([this] ()
	{
		requestStackPop();
		requestStackPush(States::Game);
	});

	auto hostPlayButton = std::make_shared<GUI::Button>(context);
	hostPlayButton->setPosition(100, 350);
	hostPlayButton->setText("Host");
	hostPlayButton->setCallback([this] ()
	{
		requestStackPop();
		requestStackPush(States::HostGame);
	});

	auto joinPlayButton = std::make_shared<GUI::Button>(context);
	joinPlayButton->setPosition(100, 400);
	joinPlayButton->setText("Join");
	joinPlayButton->setCallback([this] ()
	{
		requestStackPop();
		requestStackPush(States::JoinGame);
	});

	auto settingsButton = std::make_shared<GUI::Button>(context);
	settingsButton->setPosition(100, 450);
	settingsButton->setText("Settings");
	settingsButton->setCallback([this] ()
	{
		requestStackPush(States::Settings);
	});

	auto exitButton = std::make_shared<GUI::Button>(context);
	exitButton->setPosition(100, 500);
	exitButton->setText("Exit");
	exitButton->setCallback([this] ()
	{
		requestStackPop();
	});

	mGUIContainer.pack(playButton);
	mGUIContainer.pack(hostPlayButton);
	mGUIContainer.pack(joinPlayButton);
	mGUIContainer.pack(settingsButton);
	mGUIContainer.pack(exitButton);

	// Play menu theme
	context.music->play(Music::MenuTheme);
}
开发者ID:AlexanderButyaev,项目名称:SFML-Game-Development-Book,代码行数:59,代码来源:MenuState.cpp


示例4: requestStackPop

 bool MenuState::handleEvent(const sf::Event& event){
 #if defined ANDROID
     auto& window = *getContext().window;
     if(event.type == sf::Event::TouchEnded){
         sf::Vector2f pos = static_cast<sf::Vector2f>(window.mapPixelToCoords(sf::Vector2i(event.touch.x, event.touch.y), window.getView()));
         for(const auto& text:mOptions){
             if(text.getGlobalBounds().contains(pos)){
                 if(text.getString() == "Play"){
                     requestStackPop();
                     requestStackPush(AppStates::Game);
                 }else if(text.getString() == "Help"){
                     requestStackPush(AppStates::Help);
                 }else if(text.getString() == "Exit"){
                     requestStackPop();
                 }
             }
         }
     }else if(event.type == sf::Event::KeyReleased){
         if(event.key.code == sf::Keyboard::Escape){
             requestStackPop();
         }
     }else if(event.type == sf::Event::LostFocus){
         requestStackPop();
     }
 #else
     if(event.type != sf::Event::KeyReleased){
         return false;
     }
     if(event.key.code == sf::Keyboard::Return){
         if(mOptionIndex == Play){
             requestStackPop();
             requestStackPush(AppStates::Game);
         }else if(mOptionIndex == Help){
             requestStackPush(AppStates::Help);
         }else if(mOptionIndex == Exit){
             requestStackPop();
         }
     }else if(event.key.code == sf::Keyboard::Up){
         if(mOptionIndex > 0){
             mOptionIndex--;
         }
         else{
             mOptionIndex = mOptions.size() - 2;
         }
         updateOptionText();
     }else if(event.key.code == sf::Keyboard::Down){
         if(mOptionIndex < mOptions.size() - 2){
             mOptionIndex++;
         }else{
             mOptionIndex = 0;
         }
         updateOptionText();
     }
 #endif
     return true;
 }
开发者ID:cristianglezm,项目名称:AntFarm,代码行数:56,代码来源:MenuState.cpp


示例5: getContext

//private
void MenuHighScoreState::buildMenu(const sf::Font& font)
{
    const float centreX = xy::DefaultSceneSize.x / 2.f;

    const auto& scores = getContext().appInstance.getScores();
    auto list = xy::UI::create<xy::UI::ScoreList>(font);
    list->setAlignment(xy::UI::Alignment::Centre);
    list->setPosition(centreX, 590.f);
    list->setList(scores);
    list->setIndex(getContext().appInstance.getLastScoreIndex());
    m_uiContainer.addControl(list);

    auto upScroll = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/scroll_arrow_vertical.png"));
    upScroll->setAlignment(xy::UI::Alignment::Centre);
    upScroll->setPosition(1310, 470.f);
    upScroll->addCallback([list]()
    {
        list->scroll(list->getVerticalSpacing());
    });
    m_uiContainer.addControl(upScroll);

    auto downScroll = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/scroll_arrow_vertical.png"));
    downScroll->setAlignment(xy::UI::Alignment::Centre);
    downScroll->setRotation(180.f);
    downScroll->setPosition(1310.f, 720.f);
    downScroll->addCallback([list]()
    {
        list->scroll(-list->getVerticalSpacing());
    });
    m_uiContainer.addControl(downScroll);
    
    auto button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
    button->setString("OK");
    button->setAlignment(xy::UI::Alignment::Centre);
    button->setPosition(centreX, 875.f);
    button->addCallback([this]()
    {
        auto msg = m_messageBus.post<xy::Message::UIEvent>(xy::Message::UIMessage);
        msg->type = xy::Message::UIEvent::MenuClosed;
        msg->value = 0.f;
        msg->stateID = (m_endGame) ? States::ID::HighScoresEnd : States::ID::HighScoresMenu;

        if (m_endGame)
        {
            requestStackClear();
            requestStackPush(States::ID::MenuBackground);
        }
        else
        {
            requestStackPop();
            requestStackPush(States::ID::MenuMain);
        }
        
    });
    m_uiContainer.addControl(button);
}
开发者ID:fallahn,项目名称:LunarMooner,代码行数:57,代码来源:MenuHighScores.cpp


示例6: close

//private
void MenuPauseState::buildMenu(const sf::Font& font)
{
    const float centreX = xy::DefaultSceneSize.x / 2.f;

    auto label = xy::UI::create<xy::UI::Label>(font);
    label->setAlignment(xy::UI::Alignment::Centre);
    label->setPosition(centreX, 300.f);
    label->setString("PAUSED");
    m_uiContainer.addControl(label);
    
    auto button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
    button->setString("Continue");
    button->setAlignment(xy::UI::Alignment::Centre);
    button->setPosition(centreX, 425.f);
    button->addCallback([this]()
    {
        close();
    });
    m_uiContainer.addControl(button);

    button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
    button->setString("Options");
    button->setAlignment(xy::UI::Alignment::Centre);
    button->setPosition(centreX, 525.f);
    button->addCallback([this]()
    {
        close();
        requestStackPush(States::ID::PausedOptions);
    });
    m_uiContainer.addControl(button);

    button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
    button->setString("Quit to Main");
    button->setAlignment(xy::UI::Alignment::Centre);
    button->setPosition(centreX, 625.f);
    button->addCallback([this]()
    {
        close();
        requestStackClear();
        requestStackPush(States::ID::MenuBackground);
    });
    m_uiContainer.addControl(button);

    button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png"));
    button->setString("Exit to Desktop");
    button->setAlignment(xy::UI::Alignment::Centre);
    button->setPosition(centreX, 725.f);
    button->addCallback([this]()
    {
        xy::App::quit();
    });
    m_uiContainer.addControl(button);
}
开发者ID:fallahn,项目名称:LunarMooner,代码行数:54,代码来源:MenuPauseState.cpp


示例7: State

PlayState::PlayState(StateStack& stack, Context context) : State(stack, context), mGUIContainer() {
	sf::Texture& texture = context.textures->get(Textures::TitleScreen);
	mBackgroundSprite.setTexture(texture);
	sf::Vector2f windowSize(context.window->getSize());

	auto playButton = std::make_shared<GUI::Button>(context);
	playButton->setPosition(0.4f * windowSize.x, 0.3f * windowSize.y);
	playButton->setText("New Game");
	playButton->setCallback([this]() {
		requestStackPop();
		requestStackPush(States::Game);
	});

	auto LevelButton = std::make_shared<GUI::Button>(context);
	LevelButton->setPosition(0.4f * windowSize.x, 0.4f * windowSize.y);
	LevelButton->setText("Select Level");
	LevelButton->setCallback([this]() {
		requestStackPush(States::LevelSelect);
	});

	auto UpgradesButton = std::make_shared<GUI::Button>(context);
	UpgradesButton->setPosition(0.4f * windowSize.x, 0.5f * windowSize.y);
	UpgradesButton->setText("Ship Modifications");
	UpgradesButton->setCallback([this]() {
		requestStackPush(States::Upgrade);
	});

	auto LeaderBButton = std::make_shared<GUI::Button>(context);
	LeaderBButton->setPosition(0.4f * windowSize.x, 0.6f * windowSize.y);
	LeaderBButton->setText("Leaderboards");
	LeaderBButton->setCallback([this]() {
		requestStackPush(States::Leader);
	});


	auto backButton = std::make_shared<GUI::Button>(context);
	backButton->setPosition(0.4f * windowSize.x, 0.8f * windowSize.y);
	backButton->setText("Back");
	backButton->setCallback([this]() {
		requestStackPop();
		requestStackPush(States::Menu);
	});

	mGUIContainer.pack(playButton);
	mGUIContainer.pack(LevelButton);
	mGUIContainer.pack(UpgradesButton);
	mGUIContainer.pack(LeaderBButton);
	mGUIContainer.pack(backButton);
}
开发者ID:x00112310,项目名称:Space-Shooter-Game,代码行数:49,代码来源:PlayState.cpp


示例8: requestStackPop

bool TitleState::handleEvent(const sf::Event& event)
{
    /* Lazy way to completely abort this state -- we don't need it */
    requestStackPop();
    requestStackPush(States::Menu);

    // If the any key is pressed, trigger the next screen
    if (event.type == sf::Event::KeyPressed)
    {
        requestStackPop();
        requestStackPush(States::Menu);
    }

    return true;
}
开发者ID:vsrz,项目名称:CS699,代码行数:15,代码来源:TitleState.cpp


示例9: switch

void SelectionState::onExit(int code)
{
    switch (code)
    {
    case 3:
        emit requestStackPop();
        break;
    case 1:
    {
        QFile file("qml/HCIProject/GameScreen/current.txt");

        if (file.open(QIODevice::WriteOnly))
        {
            QTextStream out(&file);

            out << m_charSlots[m_selected]->property("charName").toString() << " ";
            out << m_charSlots[m_selected]->property("charInfo").toString();

            file.close();
        }
        emit requestStackPush(State::LOADING, false);
        break;
    }
    }
}
开发者ID:FallenShard,项目名称:hci-proj,代码行数:25,代码来源:SelectionState.cpp


示例10: requestStackPop

bool TitleState::handleEvent(const sf::Event& event) {
	if (event.type == sf::Event::KeyReleased) {
		requestStackPop();
		requestStackPush(States::Game);
	}
	return true;
}
开发者ID:SirGeoffers,项目名称:CPlusPlus-GameEngine,代码行数:7,代码来源:GameStateTitle.cpp


示例11: State

PauseState::PauseState(StateStack& stack, Context context)
: State(stack, context)
, mBackgroundSprite()
, mPausedText()
, mGUIContainer()
{
	sf::Font& font = context.fonts->get(Fonts::Main);
	sf::Vector2f windowSize(context.window->getSize());

	mPausedText.setFont(font);
	mPausedText.setString("Game Paused");	
	mPausedText.setCharacterSize(70);
	centerOrigin(mPausedText);
	mPausedText.setPosition(0.5f * windowSize.x, 0.4f * windowSize.y);

	auto returnButton = std::make_shared<GUI::Button>(*context.fonts, *context.textures);
	returnButton->setPosition(0.5f * windowSize.x - 100, 0.4f * windowSize.y + 75);
	returnButton->setText("Return");
	returnButton->setCallback([this] ()
	{
		requestStackPop();
	});

	auto backToMenuButton = std::make_shared<GUI::Button>(*context.fonts, *context.textures);
	backToMenuButton->setPosition(0.5f * windowSize.x - 100, 0.4f * windowSize.y + 125);
	backToMenuButton->setText("Back to menu");
	backToMenuButton->setCallback([this] ()
	{
		requestStateClear();
		requestStackPush(States::Menu);
	});

	mGUIContainer.pack(returnButton);
	mGUIContainer.pack(backToMenuButton);
}
开发者ID:AlexanderButyaev,项目名称:SFML-Game-Development-Book,代码行数:35,代码来源:PauseState.cpp


示例12: requestStackPush

bool GameState::handleEvent(const sf::Event& event)
{
	if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
		requestStackPush(States::Pause);

	return true;
}
开发者ID:richardahn,项目名称:Breakout,代码行数:7,代码来源:GameState.cpp


示例13: State

MenuState::MenuState(StateStack& stateStack, Context context, States::ID id)
	:
	State(stateStack, context, id),
	m_play_button(context.textures->getTexture(Textures::Button), context.fonts->getFont(Fonts::Main)),
	m_exit_button(context.textures->getTexture(Textures::Button), context.fonts->getFont(Fonts::Main)),
	m_background(*context.textures->getTexture(Textures::Titlescreen)),
	m_background_move(true),
	m_button_fade(false)
{
	// Play button
	m_play_button.setAction([this] ()
	{
		requestStackPop();
		requestStackPush(States::Game);
	});
	m_play_button.setText("Play");
	m_play_button.setPosition(1280/2, 720/2 + 40);

	// Exit button
	m_exit_button.setAction([this] ()
	{
		requestStackClear();
	});
	m_exit_button.setText("Exit");
	m_exit_button.setPosition(1280/2, 720/2 + 80);

	// Background thing
	m_background.setPosition(640 - m_background.getLocalBounds().width/2, 360 - m_background.getLocalBounds().height/2);

	context.mouse->setState(gui::Mouse::Neutral);
}
开发者ID:Oscillation,项目名称:oscMrk-II,代码行数:31,代码来源:MenuState.cpp


示例14: requestStackPop

bool LoadingState::update(sf::Time) {
    //si la tarea está creada, la continúo
    if (taskCreated) {
        if (loadingTask->isFinished()) {
            //si la tarea se ha terminado, comienzo el siguiente estado
            taskCreated=false;
            requestStackPop();
            requestStackPush(StatesID::Game);
            
        //avanzo en la completitud de la tarea
        } else {
            setCompletion(loadingTask->getCompletion());
        }
        
    //creo la tarea
    } else {
        context->actualLevel = new Level(*context->systemManager);
        std::string* level=new std::string("level1.xml");
        loadingTask = new LoadingLevel(context->nameLevel, context);
        loadingTask->execute();
        taskCreated = true;
    }
    
    return true;
}
开发者ID:DorianHawkmoon,项目名称:Graphiure,代码行数:25,代码来源:LoadingState.cpp


示例15: requestStackPush

bool GameState::update(sf::Time dt) {
    mWorld.update(dt);

    if (!mWorld.hasAlivePlayer()) {
        mPlayer.setMissionStatus(Player::MissionFailure);
        requestStackPush(States::GameOver);
    }
    else if (mWorld.hasPlayerReachedEnd()) {
        mPlayer.setMissionStatus(Player::MissionSuccess);
        requestStackPush(States::MissionSuccess);
    }

    CommandQueue& commands = mWorld.getCommandQueue();
    mPlayer.handleRealtimeInput(commands);

    return true;
}
开发者ID:WillSams,项目名称:SFML-Book-Exercises,代码行数:17,代码来源:GameState.cpp


示例16: requestStackPop

bool TitleState::handleEvent(const sf::Event& event) {
    // If any key is pressed, trigger the next screen
    if (event.type == sf::Event::KeyReleased) {
        requestStackPop();
        requestStackPush(States::Menu);
    }

    return true;
}
开发者ID:WillSams,项目名称:SFML-Book-Exercises,代码行数:9,代码来源:TitleState.cpp


示例17: switch

bool GameState::handleEvent(const sf::Event& evt)
{
    switch (evt.type)
    {
    case sf::Event::MouseButtonPressed:
    {  
        //auto position = getContext().renderWindow.mapPixelToCoords(sf::Mouse::getPosition(getContext().renderWindow));
        switch (evt.mouseButton.button)
        {
        case sf::Mouse::Left:
            //addBlock(position, blockSize);
            break;
        case sf::Mouse::Right:
            //addNpc(position);
            break;
        default: break;
        }
    break;
    }
    case sf::Event::KeyPressed:
        switch (evt.key.code)
        {
        case sf::Keyboard::Num1:

            break;
        case sf::Keyboard::Num2:
            //m_scoreBoard.enablePlayer(Category::PlayerTwo);
            break;
        case sf::Keyboard::P:
            requestStackPush(States::ID::Pause);
            break;
        default:break;
        }
        break;
    case sf::Event::JoystickButtonReleased:
        if (evt.joystickButton.button == 7)
            requestStackPush(States::ID::Pause);
        break;
    default: break;

    }
    
    return true;
}
开发者ID:John-Chan,项目名称:crush,代码行数:44,代码来源:GameState.cpp


示例18: requestStackPop

bool
LoadingState::update( sf::Time dt ) {
    if ( mLoadingTask.isFinished() ) {
        requestStackPop();
        requestStackPush( States::Game );
    } else {
        setCompletion( mLoadingTask.getCompletion() );
    }
    return true;
}
开发者ID:montreal91,项目名称:workshop,代码行数:10,代码来源:LoadingState.cpp


示例19: requestStackPop

bool TitleState::handleEvent(const sf::Event& event)
{
    if (event.type == sf::Event::KeyPressed)
    {
        requestStackPop();
        requestStackPush(States::ID::Menu);
    }

    return true;
}
开发者ID:gabrieljt,项目名称:learn-sfml,代码行数:10,代码来源:TitleState.cpp


示例20: requestStackClear

bool GameOverState::update(sf::Time dt){
	mElapsedTime += dt;

	if (mElapsedTime > sf::seconds(3)){
		requestStackClear();
		requestStackPush(States::Menu);
	}

	return false;
}
开发者ID:mrphilips,项目名称:sfml,代码行数:10,代码来源:GameOverState.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ requestTransaction函数代码示例发布时间:2022-05-30
下一篇:
C++ requestResource函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap