Mobile Input/Touch Controls
How players interact with your project is probably one of the most important things that can be established as a part of your project. While player input is added for all projects, no matter what platform you are using, this is also one area that can make or break your mobile game.
If the controls that are implemented don't fit the game that you're making, or if the controls feel clunky, players will not play your game for long stretches of time. While many people consider Rockstar's Grand Theft Auto series of games to be great on console and PC, playing the game on a mobile device provides a larger barrier of entry, due to all of the buttons on the screen and replacing joysticks with virtual versions that don't have haptic feedback in the same manner as on other platforms.
Mobile and tablet games that tend to do well typically have controls that are simple, finding as many ways to streamline the gameplay as possible. Many popular games require a single input, such as Dong Nguyen's Flappy Bird and Ketchapp's Ballz.
There are many different ways for games to interact with a mobile device that are different than for traditional games, and we will explore a number of those in this chapter.
In this chapter, we will cover the different ways that inputs will work on mobile devices. We will start off with the input that is already built into our project using the mouse, and then move on to touch events, gestures, using the accelerometer, and accessing information via the Touch class.
This chapter will be split into a number of topics. It will contain a simple, step-by-step process from beginning to end. Here is the outline of our tasks:
- Using mouse input for mobile input
- Movement via touch
- Implementing a gesture
- Scaling the player using pinches
- Using the accelerometer
- Reacting to touch