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


C++ StateManager::ChangeState方法代码示例

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


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

示例1: GameLoop

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

示例2: main

int main()
{
	SetupCallbacks();

	scePowerSetClockFrequency(333, 333, 166);

	//initialize render manager
	RenderManager::InstancePtr()->Init();
	RenderManager::InstancePtr()->CollectPerformance(true);
	RenderManager::InstancePtr()->InitDebugFont();

	//set perspectives
	RenderManager::InstancePtr()->SetOrtho(0,0,0,0,0,0);
	
	//init and load sounds
	SoundManager::Instance()->Init();

	srand(time(NULL));

	//new state manager
	StateManager stateManager;
	stateManager.Init();

	RenderManager::InstancePtr()->SetClearColour(0xFF000000);

	//splash screens
	SplashScreen *screen = new SplashScreen(TextureHelper::Instance()->GetTexture(TextureHelper::Genesis),0,0,480,272,3);
	screen->ShowSplash();
	delete screen;
	SplashScreen *screen2 = new SplashScreen(TextureHelper::Instance()->GetTexture(TextureHelper::PspTeam),0,0,424,72,3);
	screen2->ShowSplash();
	delete screen2;

	RenderManager::InstancePtr()->SetClearColour(0xFFF5B783);

	//new active state
	StateMenu *statePlay = new StateMenu();
	statePlay->Init();
	stateManager.ChangeState(statePlay);

	//trun
	while ( stateManager.Running() )
	{
		stateManager.HandleEvents();
		stateManager.Update();
		stateManager.Draw();
	}

	sceGuTerm();			// Terminating the Graphics System
	sceKernelExitGame();	// Quits Application

	return 0;
}
开发者ID:DragonNeos,项目名称:lamecraft,代码行数:53,代码来源:Lamecraft.cpp

示例3: IwMain


//.........这里部分代码省略.........
    IMAGE_BRICK1 = mgr->GetResourceManager()->RegisterImage("brick1");
    IMAGE_BRICK2 = mgr->GetResourceManager()->RegisterImage("brick2");
    IMAGE_BRICK3 = mgr->GetResourceManager()->RegisterImage("brick3");
    IMAGE_BRICK_TARGET = mgr->GetResourceManager()->RegisterImage("brick_target");

    IMAGE_STAR_0 = mgr->GetResourceManager()->RegisterImage("star_0");
    IMAGE_STAR_1 = mgr->GetResourceManager()->RegisterImage("star_1");
    IMAGE_STAR_2 = mgr->GetResourceManager()->RegisterImage("star_2");
    IMAGE_STAR_3 = mgr->GetResourceManager()->RegisterImage("star_3");
    IMAGE_STAR_4 = mgr->GetResourceManager()->RegisterImage("star_4");
    IMAGE_STAR_5 = mgr->GetResourceManager()->RegisterImage("star_5");

    FONT_TREB_16 = mgr->GetResourceManager()->RegisterFont("trebuchet16pt");
    FONT_TREB_24 = mgr->GetResourceManager()->RegisterFont("trebuchet24pt");
    FONT_TREB_36 = mgr->GetResourceManager()->RegisterFont("trebuchet36pt");

    FONT_COOPER_18 = mgr->GetResourceManager()->RegisterFont("cooper_18pt");
    FONT_COOPER_24 = mgr->GetResourceManager()->RegisterFont("cooper_24pt");
    FONT_COOPER_48 = mgr->GetResourceManager()->RegisterFont("cooper_48pt");

    SOUND_DING = mgr->GetResourceManager()->RegisterAudio("DING.wav");
    SOUND_BUZZ = mgr->GetResourceManager()->RegisterAudio("BUZZ.wav");

    GameManager::SetDebugFont(mgr->GetResourceManager()->GetFont(FONT_TREB_16));

    StateManager *state = mgr->GetStateManager();

    STATE_STARTUP = state->RegisterGameState("Startup");
    STATE_MAIN_MENU = state->RegisterGameState("MainMenu");
    STATE_LEVEL_SELECT = state->RegisterGameState("LevelSelect");

    STATE_BUGS_PLAYING = state->RegisterGameState("BugsPlaying");
    STATE_BUGS_SUMMARY = state->RegisterGameState("BugsSummary");

    STATE_APPLES_PLAYING = state->RegisterGameState("ApplesPlaying");
    STATE_APPLES_SUMMARY = state->RegisterGameState("ApplesSummary");

    STATE_SANDBOX_PLAYING = state->RegisterGameState("SandboxPlaying");
    STATE_SANDBOX_SUMMARY = state->RegisterGameState("SandboxSummary");

    STATE_WALL_PLAYING = state->RegisterGameState("WallPlaying");
    STATE_WALL_SUMMARY = state->RegisterGameState("WallSummary");

    state->DefineValidStateTransition(STATE_STARTUP, STATE_MAIN_MENU);
    state->DefineValidStateTransition(STATE_MAIN_MENU, STATE_LEVEL_SELECT);
    state->DefineValidStateTransition(STATE_LEVEL_SELECT, STATE_MAIN_MENU);

    state->DefineValidStateTransition(STATE_LEVEL_SELECT, STATE_BUGS_PLAYING);
    state->DefineValidStateTransition(STATE_BUGS_PLAYING, STATE_BUGS_SUMMARY);
    state->DefineValidStateTransition(STATE_BUGS_SUMMARY, STATE_LEVEL_SELECT);

    state->DefineValidStateTransition(STATE_LEVEL_SELECT, STATE_APPLES_PLAYING);
    state->DefineValidStateTransition(STATE_APPLES_PLAYING, STATE_APPLES_SUMMARY);
    state->DefineValidStateTransition(STATE_APPLES_SUMMARY, STATE_LEVEL_SELECT);

    state->DefineValidStateTransition(STATE_LEVEL_SELECT, STATE_SANDBOX_PLAYING);
    state->DefineValidStateTransition(STATE_SANDBOX_PLAYING, STATE_SANDBOX_SUMMARY);
    state->DefineValidStateTransition(STATE_SANDBOX_SUMMARY, STATE_LEVEL_SELECT);

    state->DefineValidStateTransition(STATE_LEVEL_SELECT, STATE_WALL_PLAYING);
    state->DefineValidStateTransition(STATE_WALL_PLAYING, STATE_WALL_SUMMARY);
    state->DefineValidStateTransition(STATE_WALL_SUMMARY, STATE_LEVEL_SELECT);

    state->SetInitialState(STATE_STARTUP);

    StateVariable initialValue;

    initialValue.intValue = 0;
    VAR_POINTS = state->RegisterVariable("GamePoints", initialValue);
    VAR_CURRENT_THINGY_COUNT = state->RegisterVariable("CurrentBugCount", initialValue);
    VAR_CURRENT_CORRECT_THINGY_COUNT = state->RegisterVariable("CorrectBugCount", initialValue);

    initialValue.stringValue = null;
    VAR_CURRENT_PHONEME = state->RegisterVariable("CurrentPhoneme", initialValue);

    // These objects do not register, so we have to delete them ourselves
    MainMenu *mainMenu = new MainMenu(mgr);
    LevelSelection *levelSelect = new LevelSelection(mgr);
    BugsLevel *bugsLevel = new BugsLevel(mgr);
    ApplesLevel *applesLevel = new ApplesLevel(mgr);
    SandboxLevel *sandboxLevel = new SandboxLevel(mgr);
    WallLevel *wallLevel = new WallLevel(mgr);

    levelSummary = new LevelSummary(mgr);

    state->ChangeState(STATE_MAIN_MENU);

    mgr->MainLoop();

    delete levelSummary;
    delete wallLevel;
    delete sandboxLevel;
    delete applesLevel;
    delete bugsLevel;
    delete levelSelect;
    delete mainMenu;

    delete mgr;
    delete wordBuilder;
}
开发者ID:david-southern,项目名称:BugSquisher,代码行数:101,代码来源:main.cpp


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