Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows下基于timer的刷新不可靠 #47

Open
eminom opened this issue Apr 18, 2014 · 2 comments
Open

windows下基于timer的刷新不可靠 #47

eminom opened this issue Apr 18, 2014 · 2 comments

Comments

@eminom
Copy link

eminom commented Apr 18, 2014

UpdateWindow之后是不是应该用如下代码刷新:
MSG msg;
while (1)
{
if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
ejoy2d_win_update();
InvalidateRect(wnd, NULL , FALSE);
if (WM_QUIT == msg.message)
{
break;
}
continue;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}

在我的机器上(Win7, Intel i3)上动画不能正常播放。

@sharpdigger
Copy link

你这是能跑多快跑多快的节奏啊!

2014-04-18 17:24 GMT+08:00 Hai Bai [email protected]:

UpdateWindow之后是不是应该用如下代码刷新:
MSG msg;
while (1)
{
if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
ejoy2d_win_update();
InvalidateRect(wnd, NULL , FALSE);
if (WM_QUIT == msg.message)
{
break;
}
continue;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}

在我的机器上(Win7, Intel i3)上动画不能正常播放。


Reply to this email directly or view it on GitHubhttps://github.com//issues/47
.

@eminom
Copy link
Author

eminom commented Apr 18, 2014

void
ejoy2d_win_update() {
static int ifirst = 1;
static DWORD last_tick = 0;
if(ifirst){
last_tick = GetTickCount();
ifirst = 0;
}
DWORD dwNow = GetTickCount();
float delta = 1.0f * (dwNow - last_tick) / 1000;
last_tick = dwNow;
//ejoy2d_game_update(G->game, 0.01f); //之前是hardcode的0.01
ejoy2d_game_update(G->game, delta);
}
这样就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants