本文整理汇总了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();
}
示例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;
}
示例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;
}