Search code examples
windowfocuslibgdx

LibGDX: is there a way to check if the window is in focus?


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.


Solution

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