pause/disable a control when the main window/activity is not visible, or when the window has lost it focus, for example: when you minimize the window or alt-tab it?
pause/disable a control when the scene is not rendered?
If I’m not wrong, the simpleapplication is not updated when it lost focus, this way the controls are not updated as well. Look at setPauseOnLostFocus().
Nice hint, I will look into those methods, maybe some idea comes out.
The fact is that I have an spatial moving until a collision checking tell it that stop; the collision checking is in a control attached to the spatial. When the main window is without focus, however the control continues running, the spatial find nothing to collide with, and it goes anywhere. I have found an alternative using this.setPauseOnLostFocus(false), so the simpleApplication never pauses… but I think that the behaviour I really want is to pause the control instead.
You’d probably want setPauseOnLostFocus (true), but I also found this to not work correctly with physics sometimes, so what I do, is onLoseFocus, I disable any external appstates (mainly bulletappstate), and disable animations and any visible particles, and change my own “game state” variable to paused. And all controls/appstates I implement check if the game is paused before running. I also show a pause screen so that the user can resume when they want.
@wezrule said:
You'd probably want setPauseOnLostFocus (true), but I also found this to not work correctly with physics sometimes, so what I do, is onLoseFocus, I disable any external appstates (mainly bulletappstate), and disable animations and any visible particles, and change my own "game state" variable to paused. And all controls/appstates I implement check if the game is paused before running. I also show a pause screen so that the user can resume when they want.
I do exactly the same, the default pause just hangs everything.