Control the direction of a game object on a mobile device

In summary, the conversation discusses different options for controlling a game (remake of Classic Snake) on mobile devices. The original game is controlled with arrow keys, but on mobile, swiping is interpreted as scrolling. One suggestion is to use touch control in the direction the user wants to move, while another is to have the user tap on an icon with arrows representing the possible directions. Another option is to tap to move the snake's current direction by 90 degrees to the right.
  • #1
Jamin2112
986
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
  • #2
Instead of using a swipe, couldn't you just detect a touch and go in that direction?
 
  • #3
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.
 

1. How can I control the direction of a game object on a mobile device?

To control the direction of a game object on a mobile device, you can use various input methods such as touch controls, accelerometer, or virtual joysticks. These can be implemented through coding or by using a game engine that supports mobile development.

2. Can I use tilt controls to direct a game object on a mobile device?

Yes, you can use the accelerometer on a mobile device to enable tilt controls for directing a game object. This allows players to physically tilt their device to control the movement or direction of the game object.

3. Are there any limitations to controlling game objects on a mobile device?

There may be some limitations depending on the specific device and its capabilities. For example, some older devices may not have an accelerometer or touch screen, which would limit the available input methods for controlling game objects. Additionally, the size and sensitivity of the controls may also affect the precision of the direction control.

4. Do I need to optimize my game for different screen sizes and orientations on mobile devices?

Yes, it is important to optimize your game for different screen sizes and orientations on mobile devices to ensure a seamless user experience. This may involve adjusting the size and placement of controls for different screen sizes, as well as implementing responsive design to accommodate different device orientations.

5. Can I customize the controls for directing game objects on a mobile device?

Yes, you can customize the controls for directing game objects on a mobile device to fit the specific needs and preferences of your game. This can include adjusting the sensitivity, placement, and size of controls, as well as offering different control options for players to choose from.

Similar threads

  • Programming and Computer Science
Replies
5
Views
3K
  • Computing and Technology
Replies
10
Views
2K
  • Computing and Technology
Replies
5
Views
3K
  • General Discussion
Replies
1
Views
8K
Back
Top