Hi everyone,
I have an application based on Simple Application and i noticed that when it loses the focus, it stops rendering.
I wanted to achieve this when i click in a certain key. How can i do this?
Regards,
check what onLoseFocus and onGainFocus does to pause it in Application I think. I presume it does speed = 0 but can’t remember. But then you also need to think about how u unpause it as your input manager won’t be able to run by default
How can i check that?
And about the way of resuming, do u have any suggestions? I was trying to make a pause that indeed stopped everything and thats what losing focus seems to do.
“pausing” your application doesn’t necessary mean that you want to suspend all action. Just stop doing that what makes your game work, e.g. disable your GamePlayAppState or whatever.
I am manking an application where the player can shoot balls. I want the ball to stop in the exact place where she is and resume after i resume. How can i achieve this?
@heldersantos-moreira said:
How can i check that?
And about the way of resuming, do u have any suggestions? I was trying to make a pause that indeed stopped everything and thats what losing focus seems to do.
Specifically responding to "How can I check that?"
All of the source code is available to you. It's not even hard to find. Scroll up to the top of your SimpleApplication subclass, right click on SimpleApplication and click "Navigate" then "Go to Source". The onLoseFocus(), etc. methods won't be in that file but navigating from there is a little test.
You might want to consider learning more about Java development before diving straight into games.
Thanks for your help.
I can’t quite understand however how exactly does the fact that i didn’t know where to find those events says something about my knowledge in the Java language. Throwing that line seems to be quite popular around here, when in fact i didn’t ask a single question related to programming or to java itself.
My question was, and is, related to the concept of the game, how to correctly pause. If i had asked how to declare a variable or hwo to make a while, that line was deserved, not in this case in my opinion. Just my 2 cents though.
Thanks again for your help, i managed to find the code and to make the pause as i wanted.
Regards,
Sorry if I misjudged you.
Usually a complete unfamiliarity with how an IDE works (in general) equates to a lack of knowledge of programming.
And never mind that for sec, on an open source project when someone points you to a method: onLoseFocus… there are half a dozen ways to track that down for anyone willing to do a small amount of leg work. And generally, programmers are used to doing that sort of legwork.
My question was, and is, related to the concept of the game, how to correctly pause and how to do that. If i asked how to declare a variable or to make a while, that line was deserved, not in this case in my opinion. Just my 2 cents though.
Someone gave you a way of finding and answer and it was too hard to figure out. This is why we get a potentially knee-jerk reaction that you are new to software development.
@pspeed said:
Someone gave you a way of finding and answer and it was too hard to figure out. This is why we get a potentially knee-jerk reaction that you are new to software development.
And despite the answer two posts above I persist in believing that.