I’m working on an Android game where the main screen is similar to Words with Friends- a grid of multiple bitmap tiles. The problem I have is with scrolling (up, down, left, right) and pinch to zoom.
Right now I’m using a surfaceview to output the tiles. To implement scrolling, I calculate the difference between touch_down and touch_up, shift the index of the top left tile accordingly, and then redraw the grid.
The problem with this is that I have to wait until the user releases their touch to move the screen, instead of a smooth scroll. I haven’t implemented pinch to zoom yet but I would run into the same problem there as well.
Is there a better way to do this?
Why not use
MotionEvent.ACTION_MOVEwhich gets fired off every time the user moves their finger on the screen instead ofMotionEvent.ACTION_DOWNorMotionEvent.ACTION_UPwhich only get fired on the touch down and touch up.Just keep track of the pointer position between
ACTION_MOVEevents and use that information to move the game board.