TFPTimer 不“滴答作响”
我正在编写一个游戏,我试图将界面和模拟器分开(两者都使用单独的计时电路运行 - 理论上动画将同步,并且模拟每秒只能运行 10 次......或其他)
我的 TFPTimer 遇到问题。它是用 Games 构造函数初始化的,如下所示:
//Create the game timer
InternalTimer := TFPTimer.Create(nil);
//Set the OnTick callback
InternalTimer.OnTimer := @OnTick;
//Set the timer interval
InternalTimer.Interval := DEFAULT_INTERNAL_TIMER; // =10
//Start the timer
InternalTimer.StartTimer;
问题是 OnTick 似乎从未被调用。我在客户端下运行了一个单独的循环,其中包含 SDL_Delay 。我需要以某种方式事件化 TFPTimer 吗?我应该给它自己的线程(还是它已经有一个线程?)关于让我的计时器工作有什么想法吗?
谢谢拉克兰
I'm writing a game which I've attempted to separate between the interface, and the simulator (both of which run with separate timing circuits - with the theory being animations will sync, and simulation can run only 10 times a second... or something)
I'm having issues with my TFPTimer. Its initialised with the Games constructor like so:
//Create the game timer
InternalTimer := TFPTimer.Create(nil);
//Set the OnTick callback
InternalTimer.OnTimer := @OnTick;
//Set the timer interval
InternalTimer.Interval := DEFAULT_INTERNAL_TIMER; // =10
//Start the timer
InternalTimer.StartTimer;
The problem is OnTick never seems to be called. I've got a seperate loop running under the client with an SDL_Delay in it. Do I need to eventise TFPTimer somehow? Should I give it its own thread (or does it already have one?) Any ideas on making my timer work?
Thanks
Lachlan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事件来自主事件循环。如果您的程序不是 Delphi/Lazarus 意义上的事件驱动的,那么它可能无法工作。
尝试在睡眠之间使用 application.processmessages
Events come from the main event loop. If your program is not eventdriven in the Delphi/Lazarus sense it will probably not work.
Try an application.processmessages inbetween sleeps