# How can I make my sprite jump up and move forward at the same time?

I'm trying to make a sprite's movements work. For some reason, he can only jump and then move, or move and then jump, but never at the same time. I'm using InputProcessor and a TiledMap system. Here's some code :

@Override
public boolean keyDown(int keycode) {
switch(keycode) {
case Keys.W:
if(canJump) {
velocity.y = speed;
canJump = false;
}
break;
case Keys.A:
velocity.x = -speed;
break;
case Keys.D:
velocity.x = speed;
break;
}
return true;
}

@Override
public boolean keyUp(int keycode) {
switch(keycode) {
case Keys.W:
velocity.y = 0;
break;
case Keys.A:
velocity.x = 0;
break;
case Keys.D:
velocity.x = 0;
break;
}
return true;
}

• Have you seen this question: gamedev.stackexchange.com/questions/57573/…? – MichaelHouse Dec 21 '13 at 6:31
• Yes I have, but I don't know how to use/implement it. Any help? – greenlittleapple Dec 21 '13 at 6:56
• Have you tried InputMultiplexer() for multiple input processors? – daniel Dec 21 '13 at 18:52
• This code should work, show the code when the velocity affects the position of your player. – Lestat Dec 22 '13 at 7:42