dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Taimeris

 
dev.gamez.lv Forum Index -> Iesācējiem
View previous topic :: View next topic  
Author Message
Lynx
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 20 Jan 2003
Posts: 70
Location: Rīga

PostPosted: Fri Oct 06, 2006 12:09 am    Post subject: Taimeris

Strādājot pie vienas programmas, nonācu strupceļā un nevaru noteikt, kur ir problēma. Teoretiski viss ir pēc manuāļa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CWnd.3a3a.SetTimer.asp un nekādi kompilācijas errori nav. Es palaižu sākuma procesā taimeri, testa nolūkā uz 1 sekundi. Ar domu, lai ik pēc sekundes tiktu izpildīts void CALLBACK TimerProc. Lieki piebilst, ka tā nenotiek.

Te izgriezums no koda:
Code:
void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
 //daram savas lietas
}
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
    MSG msg;
    HWND hWnd;   
 
SetTimer(hWnd, 0, 1000, TimerProc);
 
}
Back to top
View user's profile Visit poster's website
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Fri Oct 06, 2006 12:16 am    Post subject:

A WindowProc procedūra pareizi messedžus apstrādā? Tb nevajadzīgos ignorē un padod DefWindowProc? Vai pārbaudi SetTimer atgriezto vērtību, ka tā nav NULL? Ja ir, tad izsauc GetLastError un dabūsi error messedžu.

Vai šo ievēroji: nIDEvent [in] Specifies a nonzero timer identifier..

Vēl jau variants - izmantot idle loopu, kurš spēlēs ir daudz noderīgāks, nekā šāds timer callbaks, manuprāt.

P.S. un tu neparezi skaties. Tev te jāskatās: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/settimer.asp
Back to top
View user's profile Send e-mail
Lynx
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 20 Jan 2003
Posts: 70
Location: Rīga

PostPosted: Mon Oct 09, 2006 10:06 pm    Post subject:

Galvenā ideja lietot taimeri idle loopa vietā bija, ka taimeri var killot un lietot paralēli galvenajam loopam, ja jaapreiķina uz laiku bāzēti eventi. Kamēr ar Sleep(), jagaida kad tas beigsies.
Rezultātā tāpat nepalaidu to taimeri, izgatavoju vienkārši mainīgo time galvenajā loopā, kas katru sekundi updeitojas.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
dev.gamez.lv Forum Index -> Iesācējiem All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group