Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Interacting with touch events


The most emblematic innovation of today's smart phones is the touchscreen, which has replaced the now antique mice. A touchscreen detects, as its name suggests, touches made with fingers or styluses on a device's surface. Depending on the quality of the screen, several touches (also referred to as cursors in Android) can be handled, de-multiplying interaction possibilities.

So let's start this chapter by handling touch events in DroidBlaster. To keep the example simple, we will only handle a single "touch". The goal is to move the ship in the direction of touch. The farther the touch, the faster the ship goes. Beyond a predefined range TOUCH_MAX_RANGE, the ship's speed reaches its speed limit, as shown in the following figure:

Note

The resulting project is provided with this book under the name DroidBlaster_Part13.