Control the direction of a game object on a mobile device

Click For Summary
SUMMARY

The discussion focuses on controlling the direction of a game object, specifically a snake in a mobile version of the classic Snake game. The user is exploring alternatives to arrow key controls, as mobile devices interpret finger swipes as scrolling actions. Suggested solutions include using touch detection to change the snake's direction directly or implementing a tap system that rotates the snake's direction by 90 degrees with multiple taps. The user also considers adding directional icons for user interaction.

PREREQUISITES
  • Familiarity with mobile game development concepts
  • Understanding of touch event handling in JavaScript
  • Experience with user interface design for mobile applications
  • Knowledge of game logic implementation in JavaScript
NEXT STEPS
  • Research touch event handling in JavaScript using the Touch Events API
  • Explore user interface design principles for mobile games
  • Learn about implementing gesture recognition with Hammer.js
  • Investigate alternative control schemes for mobile games, such as virtual joysticks
USEFUL FOR

Game developers, mobile application designers, and anyone interested in enhancing user experience in mobile gaming controls.

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:
Technology news on Phys.org
Instead of using a swipe, couldn't you just detect a touch and go in that direction?
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
Replies
10
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
10K