本文整理汇总了C++中StateManager::changeState方法的典型用法代码示例。如果您正苦于以下问题:C++ StateManager::changeState方法的具体用法?C++ StateManager::changeState怎么用?C++ StateManager::changeState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateManager
的用法示例。
在下文中一共展示了StateManager::changeState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: main
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Set up screen
SDL_Surface* screen = NULL;
screen = SDL_SetVideoMode( WINWIDTH, WINHEIGHT, 32, SDL_SWSURFACE );
SDL_WM_SetCaption("Squids of the Galaxy", NULL);
//State Mananger
StateManager* stateManager = StateManager::Instance();
//Create main menu
MainMenuState* mainMenu = new MainMenuState();
stateManager->changeState(mainMenu);
//Main game loop
while (stateManager->isRunning())
{
//USER INPUT
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
stateManager->quit();
//Take user input
stateManager->userInput(&event);
}
//UPDATE
stateManager->update();
//RENDER
stateManager->display(screen);
if (SDL_Flip(screen) == -1)
return 1;
}
//Quit SDL
SDL_Quit();
return 0;
}