Control the direction of a game object on a mobile device

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
Jamin2112
Messages
973
Reaction score
12
This is more of a user experience question. I'm starting to remake a game (see http://playclassicsnake.com/play ) that works on mobile just as well as desktop. On desktop, one controls the snake (the lime green links) with the arrow keys, but I need a different way to do it on mobile. I tried using an API (http://hammerjs.github.io/) to detect finger swipes, but the problem I was encountering is that the phones interpret up and down swipes as wanting to scroll up and down on the page. I need some other way. Any ideas?

Game logic https://github.com/jamkin/Snake/blob/master/SnakeGame/Scripts/game.js .
 
Last edited by a moderator:
Physics news on Phys.org
The directions it moves are straight up, straight down, straight left, straight right. So if I have touch control the direction, do I put some icon like

directions-512.png


on the board and the user has to tap on the arrows of the icon?

Another option I thought of is having tap move the snake's current direction by 90 degrees to the right. For example, if the snake is moving to the left and the user wants to move down, they have to tap 3x very quickly.