LibGDX:有没有办法检查窗口是否对焦?(LibGDX: is there a way to check if the window is in focus?)

系统教程 行业动态 更新时间:2024-06-14 16:52:52
LibGDX:有没有办法检查窗口是否对焦?(LibGDX: is there a way to check if the window is in focus?)

我真的不确定这是否是我问题的解决方案,但这是我唯一能想到的。 我正在LibGDX中设计一个简单的平台引擎,但每当你拖动游戏窗口(或在窗口窗格上按住鼠标左键)一段时间后,当你放手时,角色会掉落在地板上,因为加速度的增加(你放手的时间越长,他放手后传送的距离越远)。 由于某种原因,拖动窗户的行为可以防止地面停止加速度的增加。 我能想到的唯一解决方案是在窗口失焦时暂停游戏,但这可能完全错误。

谢谢。

I'm really not sure if this is the solution to my problem, but it's the only thing I can think of. I'm designing a simple platforming engine in LibGDX, but whenever you drag the game window (or hold the left mouse button over the window pane) for a certain period of time, when you let go the character will fall through the floor due to a build up of acceleration (the longer you hold it the further he'll teleport down after letting go). For some reason the act of dragging the window prevents the ground from stopping the acceleration buildup. The only solution I can think of is to pause the game when the window is out of focus, but that might be completely wrong.

Thanks.

最满意答案

我通过仅在deltaTime足够小时更新位置来解决它,因为deltaTime在拖动窗口时增加。

I solved it by only updating the position if deltaTime is small enough, since deltaTime increases while the window is being dragged.

更多推荐

本文发布于:2023-04-05 12:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/39362438458c1d15604c38859d18a4dc.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   对焦   窗口   LibGDX   window

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!