jME3 HelloInput Tutorial Help

Greetings Programs,



First of all, I'm really enjoying working with JME3. So far it is really working fairly well. Keep up the great work.



I've been going through the HelloJME3 tutorial series and I have been really learning a lot from those tutorials so thanks a lot to whoever has been writing these (says last modified by Zathras?). Anyway, I'm on the HelloInput lesson and I have a little issue that I couldn't find on the forums.



In the exercises section, the author challenges us to make the P key a pause button. Seems easy enough…so I was able to do it but I noticed that it just rapidly switches the isRunning flag from true to false so once you let go of the P key the game can still be paused! Even if you just tap it quickly the flag can easily change a few times. Is there a way yet to make it so that once a key is pressed it just does one thing? In other words, make it so that if the user presses and holds the P key it just switches the isRunning flag once, no matter how long he/she holds it?



Thanks for any help. I'll keep looking to see if I can figure this out.





By the way, here is my code for registering the P key and what the binding should do when the P key is pressed.


//from the initKeys() method
inputManager.registerKeyBinding("Pause", KeyInput.KEY_P);

//from the onBinding() method
if(binding.equals("Pause"))
{
    _isRunning = !_isRunning;

    //Used to see that the flag rapidly switches while P key is down.
    System.out.println(_isRunning);
}




Happy coding,

Jack

That's strange… I was just thinking exactly the same thing XD

I'm not sure how to fix it, I know with Java's default key listeners, you can listen for pressed and released, but I'm not sure if you can do that with jME3  :frowning:

The Input system is awaiting a makeover. Once its done you'll be able to listen to changes to the binding, so you can detect when a key has been pressed for example by checking if value>0 and changed=true.

Momoko_Fan said:

The Input system is awaiting a makeover. Once its done you'll be able to listen to changes to the binding, so you can detect when a key has been pressed for example by checking if value>0 and changed=true.


Alright, sounds great! I figured that was the issue. I mean it isn't called "Alpha" stage for nothing.  XD
I'm just glad to know that the team is aware of the issue.  :D


Thanks!