本文整理汇总了C++中Engine::ChangeState方法的典型用法代码示例。如果您正苦于以下问题:C++ Engine::ChangeState方法的具体用法?C++ Engine::ChangeState怎么用?C++ Engine::ChangeState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine::ChangeState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Engine game;
// initialize the engine
if(!game.Init("10 Seconds")) {
return 1;
}
game.window.setJoystickThreshold(10);
game.ChangeState(GMenuState::Instance());
// main loop
while(game.Running()) {
game.HandleEvents();
game.Update();
if(game.Running())
game.Draw();
}
// cleanup the engine
game.Cleanup();
return 0;
}
示例2: main
int main(int argc, char *argv[])
{
json_object * str = json_object_new_string("cunt\n");
std::cout << "My string is " << json_object_get_string(str);
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
// error!
}
CFRelease(resourcesURL);
chdir(path);
std::cout << "Current Path: " << path << std::endl;
#endif
#ifdef _DEBUG
#ifdef __LINUX__ // !!!! MOVE THIS TO MAIN STARTUP !!!!
const std::string delim = "/"
#else
const std::string delim = "\\";
#endif // __LINUX__
std::string log_file = "Logfiles" + delim + "tiles.txt";
LOG_SET_FILENAME(log_file.c_str());
#endif // _DEBUG
std::cout << getwd << std::endl;
Engine engine;
if (!engine.Initialise())
return -1;
engine.ChangeState(SplashState::GetInstance());
while (engine.IsRunning())
{
engine.HandleEvents();
engine.Update();
engine.Render();
}
#ifdef _DEBUG
LOG_WRITE_FILE;
#endif
return 0;
}
示例3: main
int main( int argc, char* argv[] )
{
int iLevelWidth = 1024;
int iLevelHeight = 768;
Initialise(iLevelWidth, iLevelHeight, false, "Game!");
Engine Game;
Game.ChangeState(IntroState::Instance());
do
{
Game.Update();
} while ( FrameworkUpdate() == false );
Shutdown();
return 0;
}
示例4: main
int main ( int argc, char *argv[] )
{
Engine game;
// initialize the engine
game.Init( "Splatter", 1200, 600 , 0, false);
// load the intro
game.ChangeState( MainMenuState::Instance());
// main loop
while ( game.Running() )
{
game.HandleEvents();
game.Update();
game.Draw();
SDL_RenderPresent(game.renderer);
}
// cleanup the engine
game.Cleanup();
return 0;
}
示例5: StartUpBeforeCreateWindow
void StartUpBeforeCreateWindow()
{
#if defined(IPHONE)
std::string dataDir = GetDataDir();
std::cout << "Data Dir: " << dataDir << "\n";
File::SetRoot(dataDir, "/");
#endif
#ifdef GEKKO
// TODO Better to put this in library main() if we can get the app's directory
File::SetRoot("/apps/amju_scp/data/", "/");
#endif
#if defined (AMJU_USE_BASS)
TheSoundManager::Instance()->SetImpl(new BassSoundPlayer);
#endif
GlueFile* gf = new GlueFileMem;
gf->SetPrintUnusedInDtor(true);
if (!FileImplGlue::OpenGlueFile(GLUE_FILE, gf))
{
ReportError("Failed to open data glue file");
return; // TODO false;
}
GlueFile* pMusicGlueFile = new GlueFileMem;
if (pMusicGlueFile->OpenGlueFile(MUSIC_GLUE_FILE, true)) // true = read only
{
TheSoundManager::Instance()->SetGlueFile(pMusicGlueFile);
}
else
{
ReportError("Failed to open music glue file");
return; // TODO false;
}
/*
// TODO Other languages - preferences
if (!Localise::LoadStringTable("english.txt"))
{
ReportError("No localise string table.");
}
// Add resource loaders
TheResourceManager::Instance()->AddLoader("obj", ObjLoader);
TheResourceManager::Instance()->AddLoader("font", FontLoader);
TheResourceManager::Instance()->AddLoader("mod", BinaryResourceLoader);
TheResourceManager::Instance()->AddLoader("snd", BinaryResourceLoader);
TheResourceManager::Instance()->AddLoader("wav", BinaryResourceLoader);
// Add SceneNode types to factory
TheSceneNodeFactory::Instance()->Add(SceneNode::NAME, &SceneNode::Create);
TheSceneNodeFactory::Instance()->Add(SceneMesh::NAME, &SceneMesh::Create);
TheResourceManager::Instance()->LoadResourceGroup("2dtext-group");
TheHud::Instance()->Load();
#ifdef BYPASS_TITLE
// TODO Only needed if we bypass title
TheResourceManager::Instance()->LoadResourceGroup("3dtext-group");
TheResourceManager::Instance()->LoadResourceGroup("gui-group");
TheLevelManager::Instance()->SetLevelId(1);
StartGame(1, AMJU_MAIN_GAME_MODE); // TODO two player etc
TheGame::Instance()->SetCurrentState(GSLoadLevel::NAME);
#else
TheGame::Instance()->SetCurrentState(TheGSLogo::Instance());
#endif
*/
#ifdef GEKKO
TheCursorManager::Instance()->Load(Vec2f(0.025f, -0.08f)); // position hotspot
#endif
Engine* engine = Engine::Instance();
engine->ChangeState(EsLogo::Name, Engine::IMMEDIATE);
engine->GetGameState()->SetName("gs.cfg");
engine->GetGameState()->Load();
ConfigHack(); // set config from auto-generated source file.
#ifdef MACOSX
std::string root = "./"; //GetRoot();
std::cout << "Root is " << root.c_str() << "\n";
File::SetRoot(root, "/");
#endif
#ifdef _DEBUG
std::cout << "main(): got root\n";
#endif
engine->LoadConfigFile(GAME_CFG);
engine->InitGl();
TheGame::Instance()->SetCurrentState(engine);
}