Ok, I'm creating an RPG style game with FX and need help with key inputs. Basically whenever the user presses the arrow keys (down, left, right, up) the player character will move on the map. This all works well enough but I need to be able to have the player run. So I'm using the SHIFT key for running. The problem comes when I press the shift key. If I have one of the arrow keys pressed down when I press the shift key it cancels the current arrow key and I have to press it again to move. So basically if I press shift and then an arrow key it works fine but if I press the arrow key and then shift the player stops moving. The code for when I press the shift key simply increases a variable called "moveSpeed" by 1 ( it should do this without cancelling the keys I already have pressed) and when I release the shift key it decreases "moveSpeed" by 1. I've tried key combinations with arrow keys and "shift.down" and I've tried just single keycode.shift but it always stops the current key press. I have a <KeyEvent> that handles all of this together.
Well being 1AM I'm not going to test this tonight but your code looks very good. I'll test it tomorrow and let you know. I'm still trying to get used to JavaFX with all the timers and and animation abilities.
Joined: Jan 04, 2014
Sorry for the double post but I wanted to let John Damien Smith know that the code you posted worked absolutely perfectly! Everything about it is streamline. There's no glitchiness (not a word, I know lol) in the movement and the running works just like it should. Thanks much!
I have another question about javafx actually. I need to be able to adjust the "z" values of nodes within a javafx pane. I know you can use a stackpane but stackpane does not work for me because I need absolute positioning of the nodes (ie the player walking around the map). So I've resorted to using just regular Pane but whenever I try to change the index of a node within the Pane it doesn't draw it above or behind another. I'm not sure why. I've went as far as clearing the node and adding all the children back in a certain order but the depth is never changed for some reason. Basically, my player that is walking around the screen needs to be on top of other characters if his "y" value is greater than theirs. If the player's "y" value is less than it needs to appear that he's behind the other characters. Any ideas?
John Damien Smith
Joined: Jan 26, 2012
Can you ask you question in a new question and include an sscce?