In this chapter, we are going to cover a few examples of frequently used mobile-specific UI interactions.
Examples
Adding press-and-hold/long-press functionality
Press-and-hold is utilized frequently in mobile games. Many games that use right-click on the PC or web use press-and-hold when they are converted to the mobile platform.
To demonstrate how to implement Press and Hold functionality, we will create a button that has a growing ring that represents hold time. Once a specified amount of time has passed, a function will fire:
![](https://static.packt-cdn.com/products/9781787125520/graphics/assets/04bf2528-be85-4a85-9a9a-5eb06f0aca4d.png)
When working this example, it is important to remember that even though the code is referencing a pointer, this functionality does not work exclusively with a mouse. Placing a finger on a touchscreen...