本文整理汇总了C++中Menu::SetState方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::SetState方法的具体用法?C++ Menu::SetState怎么用?C++ Menu::SetState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::SetState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wWinMain
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
g_hInstance = hInstance; // Store application handle
g_bWindowed = true; // Windowed mode or full-screen
// Init the window
InitWindow();
// Use this msg structure to catch window messages
MSG msg;
ZeroMemory(&msg, sizeof(msg));
//perform the count for frames per second
_int64 cntsPerSec = 0;
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);//perform function QueryPerformanceFrequency: returns a BOOL value; true if timer exist
float secsPerCnt = 1.0f / (float)cntsPerSec; //typecast the long int into a float
//create an int for prev time
_int64 prevTimeStamp = 0;
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
//*************************************************************************
// Initialize DirectX/Game here (call the Init method of your framwork)
DXObj.Init(g_hWnd, g_hInstance, g_bWindowed);
MenuObj.Init(g_hWnd, g_hInstance, g_bWindowed);
//*************************************************************************
// Main Windows/Game Loop
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//begin current time stamp counter
_int64 currTimeStamp = 0;
//receive counter performance
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
float dt = (currTimeStamp - prevTimeStamp)*secsPerCnt;
if(MenuObj.GetState() == 0) // Intro movie
{
DXObj.Update(dt);
if(DXObj.GetMovieState() == true)
{
MenuObj.SetState(1);
}
}
if(MenuObj.GetState() == 1)
{
//menu
MenuObj.Update();
MenuObj.Draw();
}
if(MenuObj.GetState() == 2)
{
//options
MenuObj.Update();
MenuObj.Draw();
}
if(MenuObj.GetState() == 3)
{
//game
if(!g_bIsEnabled)
{
PFObj.Init(g_hWnd, g_hInstance, g_bWindowed);
g_bIsEnabled = true;
}
PFObj.Update(dt);
PFObj.Draw();
if(PFObj.GetMenuBool())
{
MenuObj.SetState(1);
}
}
if(MenuObj.GetState() == 4)
{
//credits
MenuObj.Update();
MenuObj.Draw();
}
if(MenuObj.GetState() == 5)
{
//quit game
DXObj.Shutdown();
PostQuitMessage(0);
}
//*************************************************************************
// This is where you call your DirectXFramework/Game render/update calls
//MenuObj.Draw();
//PSObj.Draw();
//*************************************************************************
//Prepare for the next iteration: The current time
//stamp becomes the previous time stamp for the next iteration
prevTimeStamp = currTimeStamp;
}
//*************************************************************************
//Shutdown DirectXFramework/Game here
//.........这里部分代码省略.........