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


C++ StateManager类代码示例

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


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

示例1: if

/** Called when the user clicks on a widget.
 *  \param widget that was clicked on.
 *  \param name Name of the widget.
 *  \param playerID The id of the player who clicked the item.
 */
void LoginScreen::eventCallback(Widget* widget, const std::string& name, 
                                const int playerID)
{
    if (name == "login_tabs")
    {
        StateManager *sm = StateManager::get();
        const std::string selection = 
            ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);

        if (selection == "tab_guest_login")
            sm->replaceTopMostScreen(GuestLoginScreen::getInstance()); 
        else if (selection == "tab_register")
            sm->replaceTopMostScreen(RegisterScreen::getInstance());
    }
    else if (name=="options")
    {
        const std::string button = 
             getWidget<RibbonWidget>("options")
             ->getSelectionIDString(PLAYER_ID_GAME_MASTER);
        if(button=="sign_in")
        {
            login();
        }
        else if(button=="recovery")
        {
        }
        else if(button=="cancel")
            StateManager::get()->escapePressed();
    }

}   // eventCallback
开发者ID:Shreesha-S,项目名称:stk-code,代码行数:36,代码来源:login_screen.cpp

示例2: main

int main(int argc, char *argv[])
{
	UNUSED(argc);
	UNUSED(argv);

	try
	{
		Globals::init();
		Arguments::parse(argc, argv);
		Utils::Random::seed();
		Ncurses::init();
		Colors::init();

		StateManager states;
		states.run();

		Ncurses::exit();
	}
	catch (...)
	{
		// I dont really have a nice exception-handling scheme right
		// now. I must learn how to properly deal with them.
		Ncurses::exit();
		return 666;
	}

	return 0;
}
开发者ID:LoisG,项目名称:yetris,代码行数:28,代码来源:main.cpp

示例3: update_belief

 /**
  * Receive all messages and compute the new belief. 
  */
 inline void update_belief(const vertex_type& vertex,
                           StateManager& state) {
   
   // Get the belief from the state manager
   belief_type* blf = state.checkout_belief(vertex);
   // Wipe out the old value for the belief
   if(vertex.is_variable()) {
     *blf = 1;
   } else if(vertex.is_factor()) {
     *blf = vertex.factor();
   } else {
     assert(false);
   }
   // For each of the neighbor variables 
   foreach(const vertex_type& vertex_source, state.neighbors(vertex)) {
     // get the in message
     message_type* in_msg = 
       state.try_checkout(vertex_source, vertex, Reading);
     if(in_msg != NULL) {
       // Combine the in_msg with the destination factor
       blf->combine_in(*in_msg, csr_.dot_op);
       // return the message to the state manager
       state.checkin(vertex_source, vertex, in_msg);
       // normalize the belief
       blf->normalize();
     }
   }  
   // Do an extra normalization (just in case no messages were
   // available)
   blf->normalize();
   // ASSERT WE BLF IS A VALID DISTRIBUTION (we should check this)
   // Save the belief
   state.checkin_belief(vertex, blf);
 }// End of update belief    
开发者ID:vdeepak13,项目名称:sill,代码行数:37,代码来源:fast_update_rule.hpp

示例4: main

int main (int argc, char * argv[])
{
    Window::getInstance()->create(1366, 768, "inspector gadget!", true);

    Input * input = Input::getInstance();
    if(ifstream("data/preferences.ini"))
        input->loadKeymapping("data/preferences.ini");
    else
    {
        input->addMapping("escape", SDLK_ESCAPE);
        input->addMapping("enter", SDLK_RETURN);
        input->addMapping("up", SDLK_UP);
        input->addMapping("down", SDLK_DOWN);
        input->addMapping("left", SDLK_LEFT);
        input->addMapping("right", SDLK_RIGHT);
        input->saveKeymapping("data/preferences.ini");
    }

    StateManager * stateman = StateManager::getInstance();
    stateman->changeState(new state::GameState());
    stateman->run();

    std::cout << "bye\n";
    return 0;
}
开发者ID:DZvO,项目名称:chatter,代码行数:25,代码来源:main.cpp

示例5: getFromStates

void RouteTable::getFromStates(const State& toState,
	std::set<State*>& fromStates) {
	// if didn't found, then just return
	const std::string& toStateName = toState.name();
	StateMapConstIterator it = mapToStateToFromStates.find(toStateName);
	if (it == mapToStateToFromStates.end()) {
		std::cout << "RouteTable:: state \"" << toState
			<< "\" didn't have any other state directed to"
			<< std::endl;
		return;
	}
	
	StateManager* stateManager = StateManager::instance();
	fromStates.clear();
	const std::set<std::string>& fromStateNames =
		mapToStateToFromStates[toStateName];
	for (std::set<std::string>::const_iterator it = fromStateNames.begin();
		it != fromStateNames.end(); ++it) {
		const std::string& fromState = *it;
		State* state = stateManager->getState(fromState);
		if (state)
			fromStates.insert(state);	
	}
	return;
}
开发者ID:yzard,项目名称:generic-gameengine,代码行数:25,代码来源:RouteTable.cpp

示例6: main

int main(int argc, const char* argv[])
{


	ResourceLoader loader(argv[0] + std::string("\\..\\..\\Resources"));
	


	StateManager states;
	states.setState(std::unique_ptr<MenuScreen>(new MenuScreen(loader)));


	sf::RenderWindow app(sf::VideoMode(768, 768, 32), "Ethan Game");
	app.EnableKeyRepeat(false);
	
	sf::Clock clock;
	double timeForSimulation = 0;

	while (app.IsOpened())
	{
		
		sf::Event event;
		while (app.GetEvent(event))
		{
			switch(event.Type)
			{
			case sf::Event::Closed:
				app.Close();
				break;

			default:
				states.handleEvent(event);
			}
				
		}
		timeForSimulation+= clock.GetElapsedTime();
		clock.Reset();

		while (timeForSimulation >= 1.0/60.0)
		{
			states.update(1.0/60.0);
			timeForSimulation -= 1.0/60;
		}

	

		states.draw(app);


		app.Display();

	}



	return 0;
}
开发者ID:Lalaland,项目名称:EthanSteinbergFinalProject,代码行数:57,代码来源:Main.cpp

示例7: main

int main()
{
	StateManager manager;

	manager.pushState(new PlayState(&manager));
	manager.gameLoop();

	return 0;
}
开发者ID:Troussierj13,项目名称:Target,代码行数:9,代码来源:main.cpp

示例8: while

void GameEngine::GameLoop()
{
    // Set framerate cap
    GLdouble framerate = 999.0;
    GLdouble lastFrameTime = 0, currentFrameTime = 0, fpsLastUpdate = 0;
    gameRunning = true;

    // Main-loop
    while(gameRunning)
    {
        currentFrameTime = glfwGetTime();
        if ((currentFrameTime - lastFrameTime) * 1000.0 < 1000.0 / framerate)
        {
            Sleep(0.0001);
        }
        else
        {
            // Check if a state has been queued
            if (StateManager::GetInstance()->StateHasBeenQueued())
            {
                StateManager *sM = StateManager::GetInstance();
                ResourceManager * rM = ResourceManager::GetInstance();

                // Change state
                rM->UnloadAll();
                sM->ChangeState(sM->GetQueuedState());
                rM->StartLoading();
            }

            // Handle input
            HandleInput();

            // Update
            Update((currentFrameTime - lastFrameTime) * 1000.0);

            // Draw
            Draw();

            // update fps-counter
            GLdouble time = currentFrameTime;
            if (time - fpsLastUpdate >= 1.0)
            {
                GLdouble fps = ((currentFrameTime - lastFrameTime) * 1000.0);
                glfwSetWindowTitle(Context::getWindow(), toString((int)((1000.0 / fps) * 100.0) / 100.0).c_str());
                fpsLastUpdate = time;
            }

            lastFrameTime = currentFrameTime;
        }
    }

    // Cleanup game if loop stops
    Cleanup();
}
开发者ID:Landeplage,项目名称:Amigo,代码行数:54,代码来源:GameEngine.cpp

示例9: RunTest

void RunTest()
{
    StateManager stateManager;
//    stateManager.Process(0);

    stateManager.Push(Splash, NULL);
    stateManager.Process(NULL);

    stateManager.Pop();

}
开发者ID:lalanotlistening,项目名称:lalagame,代码行数:11,代码来源:Startup.cpp

示例10: changeVarValue

int32 changeVarValue(void *v1, void *v2)
{
    StateManager *stateManager = (StateManager *)v1;
    EventCallback *callbackData = (EventCallback *)v2;
    StateVariable curVal = stateManager->GetStateVar(FLOAT_VAR_HANDLE);
    curVal.floatValue += 1.1f;
    stateManager->SetStateVar(FLOAT_VAR_HANDLE, curVal);

    curVal.intValue = (int)curVal.floatValue;
    stateManager->SetStateVar(INT_VAR_HANDLE, curVal);
    stateManager->PostFutureEvent("FloatChange", NULL, callbackData->gameTime + 3000);
    return 0;
}
开发者ID:david-southern,项目名称:BugSquisher,代码行数:13,代码来源:test_main.cpp

示例11: canTransition

	//根据状态机判断当前状态是否可以切换到目标状态
	bool PostureState::canTransition(StateMachine* self,State* targetState)
	{
		bool ret = false;
		do{
			if( self->getBlocked() ) break;												//状态机阻塞则返回
			State* CurrentPostureState = self->getCurrentPostureState();				//得到当前状态
			sStateCode CurrentStateCode = CurrentPostureState->getCode();
			sStateCode targetStateCode = targetState->getCode();
			StateManager* stateManage = self->getStateManage();							//状态管理器
			if( stateManage->isInTransitionVec(self,CurrentStateCode,targetStateCode))	//判断当前状态是否可以切换至目标状态
			{
				ret = true;
			}
		} while (0);
		return ret;
	}
开发者ID:54993306,项目名称:Classes,代码行数:17,代码来源:PostureState.cpp

示例12: update

void SFMLMenu::update(StateManager& manager)
{
  sf::Event	event;
  while (this->_window->pollEvent(event))
    {
      switch (event.type)
	{
	case sf::Event::Closed:
	  this->_window->close();
	  manager.exit();
	  break;

	case sf::Event::TextEntered:
	  if (event.text.unicode == 13)
	    {
	      this->connect();
	      manager.pushState(new StateRoom(this->_window, this->_world, this->_music));
	    }
	  else if (event.text.unicode == 8)
	    this->_textboxIP->removelastCharacter();
	  else
	    {
	      if ((event.text.unicode < '0' || event.text.unicode > '9') && event.text.unicode != '.')
		return;
	      this->_textboxIP->addCharacter(static_cast<char>(event.text.unicode));
	    }
	  break;
		case sf::Event::MouseButtonPressed:
			if (this->_buttonplay->isMouseOnButton())
			{
				this->connect();
				manager.pushState(new StateRoom(this->_window, this->_world, this->_music));
			}
			else if (this->_buttonCredit->isMouseOnButton())
				manager.pushState(new StateCredit(this->_window));
			else if (this->_buttonSolo->isMouseOnButton())
			  {
			    this->_music->stop();
			    manager.pushState(new StateSoloGame(this->_world));
			  }
			return;
	default:
	  break;
	}
    }
}
开发者ID:deb0ch,项目名称:R-Type,代码行数:46,代码来源:SFMLMenu.cpp

示例13: main

//-----------------------------------------------------------------------------
// Entry point for the application.
//-----------------------------------------------------------------------------
int main ( )
{
	// Create our state manager.
	StateManager stateManager;

	// Push a new TestStateOne object into our stateManager object.
	// When we do this the state manager internally calls the
	// Init() function of the state being pushed in. 
	stateManager.Push( new TestStateOne ( ) );
	
	// The frame() function of the stateManager object calls the 
	// frame() function of the current state.  This is the place 
	// where all logical syntax will be executed. 
	stateManager.Frame();

	// The render() function of the stateManager object calls the
	// render() function of the current state.  This is the place
	// where all rendering syntax will be executed.
	stateManager.Render();

	// We now are pushing a TestStateTwo object into our stateManager 
	// object.  The testStateOne object still exist inside our
	// stateManager. Because the testStateTwo object is at the top
	// of the internal stateManager vector container, it takes focus. 
	stateManager.Push( new TestStateTwo ( ) );
	stateManager.Frame();
	stateManager.Render();

	// We now are removing the current state from stateManager.
	// This means testStateOne is back in focus.  This is where
	// any custom shutdown syntax would go.
	stateManager.Pop();

	// For demonstration purposes we are going to go ahead and 
	// push a new TestStateTwo object into the stateManager.
	stateManager.Push( new TestStateTwo ( ) );

	// By calling this function we are going to be removing both
	// the testStateOne object and the testStateTwo object from 
	// our stateManager.
	stateManager.PopAll();

	return 0;
}
开发者ID:chad-ramos,项目名称:state-machine,代码行数:47,代码来源:Main.cpp

示例14: if

/** Called when an event occurs (i.e. user clicks on something).
*/
void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
                                      const int playerID)
{
    if (m_profile_tabs && name == m_profile_tabs->m_properties[PROP_ID])
    {
        std::string selection =
            ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
        StateManager *sm = StateManager::get();
        if (selection == m_friends_tab->m_properties[PROP_ID])
            sm->replaceTopMostScreen(OnlineProfileFriends::getInstance());
        else if (selection == m_achievements_tab->m_properties[PROP_ID])
            sm->replaceTopMostScreen(TabOnlineProfileAchievements::getInstance());
        else if (selection == m_settings_tab->m_properties[PROP_ID])
            sm->replaceTopMostScreen(OnlineProfileSettings::getInstance());
    }
    else if (name == "back")
    {
        StateManager::get()->escapePressed();
    }
}   // eventCallback
开发者ID:toymak3r,项目名称:Beyond-The-Mirror---Weird-Rancing-Game,代码行数:22,代码来源:online_profile_base.cpp

示例15: main

    int main(int argc, char *argv[])
#endif
    {
        srand(time(NULL));
        // Create application object
        StateManager* app = StateManager::getInstance();
        
        try {
            app->run(PlayState::getInstance());
        } catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
            MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
            std::cerr << "An exception has occured: " <<
                e.getFullDescription().c_str() << std::endl;
#endif
        } catch (std::exception& e) {
            MessageBox( NULL, e.what(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
        }

        return 0;
    }
开发者ID:juchi,项目名称:TowerDefense,代码行数:22,代码来源:main.cpp


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