my movement is working good on keyboard but on android its not

| | August 11, 2015

So basically here is what my movement is like for keys:

key down

 if (keycode == Keys.LEFT) {
                mishi.getAcceleration().x = -13;
            }

key up

if (keycode == Keys.LEFT) {
            mishi.getAcceleration().x = 0;
            mishi.getVelocity().x = 0;
            mishi.setRotation(0);
        }

touch down

            if (x >= 0 && x < 1 && y > 5 && y < 8) {
                mishi.getAcceleration().x = -13;
            }

touch up

if (x >= 0 && x < 1 && y > 5 && y < 8) {
            mishi.getAcceleration().x = 0;
            mishi.getVelocity().x = 0;
            mishi.setRotation(0);
        }

So its basically the same thing, however, on android when I move around my player doesn’t stop he just keeps going. Its hard to explain but it just feels and looks wrong, you have to touch around to get it to work properly but its unplayable. I think it has to do with the fact that I am moving with 2 touches but not sure how to handle it. I tried adding 2 input processes and combining them but it produced the same results.

I saw some code online using a map to hold in the pointers but I am not sure how to utilize those pointers in this scenario where 2 keys being pressed are both for movement and they need to be combined so that I can move up/right or down/left diagonally.

One Response to “my movement is working good on keyboard but on android its not”

  1. I am not incredibly familiar with mobile interface processing but my understanding of your question is that you want the user to be pressing both up and left at the same time on the device? This seems to be a little counter intuitive, while on a computer it is natural to press two keys at a time but for a mobile device you would only want to press once.

    My suggestion would be to have a single input from the device and depending on the angle of that press from the origin of the directional pad (or however the user determines where to press) and conclude from there whether they are intending to go left, up, or both.

    Lastly, if you think your input is being processed twice and you aren’t moving how you expect then that could very well be the case but it would most likely have to do with your code.

    EDIT: Also you may want to take a look over at this question: http://gamedev.stackexchange.com/a/35594/40821

Leave a Reply