The problem with timer

Started by
1 comment, last by Zao 17 years, 2 months ago
Hi i have some problem to use the settimer() function, i don't know what wrong with the code, because it didn't work. My coursework is develop a game by using the Directx, and my game have a 60 second time limit, so i used SetTimer() to do it, but not working . Wish anyone could help me. declared timer at the global
Quote: #define Timer 16
i called the settimer function at the main function
Quote: INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int) { xxxxxxx xxxx SetTimer(hwnd, Timer, 1000, NULL); xxxx xxx }
then the "Timer" appeared at the MsgProc function agains, i put a few break point like below, but the program didn't run throw these part, I think it's because the uMsg not equal to WM_COMMAND or WM_TIMER, but i refer oth people example, the example of other people can work, but don't know why i used it in the same way, but it didn't work in my code.
Quote: LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing ) { // Give the dialogs a chance to handle the message first *pbNoFurtherProcessing = g_SampleUI.MsgProc( hWnd, uMsg, wParam, lParam ); if( *pbNoFurtherProcessing ) return 0; else { switch( uMsg) { BREAK POINT-> case WM_COMMAND: switch( LOWORD(wParam) ) { case IDC_START: InitPlayingScene(d3dDevice); break; } BREAK POINT-> case WM_TIMER: { switch (wParam) { BREAK POINT---> case Timer: if ( Scene == PlayingScene ) { TimeLeft--; if( TimeLeft == 0 ) { InitResultScene(); Scene = ResultScene; } } else if(Scene == PractiseScene ) { TimeLeft--; if( TimeLeft == 0 ) { InitIntroScene(); Scene=IntroScene; } } break; } } } } }
Advertisement
Moved to For Beginners.
Maybe your timer is caught by the MsgProc of the g_SampleUI?

To make it is hell. To fail is divine.

This topic is closed to new replies.

Advertisement