首页>itarticle>(recycle from past) game loop update in c#
(recycle from past) game loop update in c#
admin11月 11, 20200
Game loop in C# Game update loop is a problem in C#. Of course, first thought of us must be attach the Idle event of Application, like this.
1
2
3
4
5
6
7
8
9
Application.Idle += new EventHandler(OnAppIdle);
Application.Run(mMainFrame);
static void OnAppIdle(object sender, EventArgs e)
{
//Do some game loop update here
mMainFrame.DoUpdate();
}
It seems reasonable, we register a listener to Idle event, so it must be run OnAppIdle while application idle, right?
Partially right.
When the application keep going, it will only get message while “When application need to be updated”. It means, therefore, if you leave mouse out of this application form(so no MouseMove event sent), it will totally stop, so it will be updated only when getting some message : such like OnMouseMove….etc.
Solution is from Rich, and he found it in sample of MDX applications. Don’t ask me how to do it, just need to know use this way to keep the game loop.
近期评论