I am currently developing a game for Android. One of the things I am working on is moving the map by touch.
This is the code that handles getting speed, which is then added to the screens position and the next update draws the corresponding portion of the map.
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (released) {
touchX = event.getX();
touchY = event.getY();
released = false;
}
else {
float newX = event.getX();
float newY = event.getY();
speedX = (int) (newX - touchX);
speedY = (int) (newY - touchY);
touchX = newX;
touchY = newY;
}
return true;
case MotionEvent.ACTION_UP:
released = true;
return true;
}
return false;
}
It works fine, it does. But it seems like it is not enough of a fluid movement.
Does anyone have any idea of how I can make it more like a seamless motion?
EDIT:
And just for info, my fps is currently 80. So I do not believe it is caused by the bitmap drawing itself.