This example MIDlet shows you how to use the Gesture API to implement touch interaction in a game application. This example also covers some key points to consider when developing a game for the Nokia Asha software platform and Series 40.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Application Descriptor


This application demonstrates the Gesture API and Sensor API. It also shows some keypoints to consider when developing a game for Nokia Asha software platform and Series 40 phones.

This example demonstrates:

  • using Gesture API
  • using Sensor API
  • creating a performance optimised game for Nokia Asha and Series 40 phones

The application is hosted in GitHub:

For more information on the implementation, visit Java Developer's Library:

  1. Prerequisites

  • Java ME basics
  • Java ME threads and timers
  • Trigonometry
  1. Important files and classes


  • src\..\
  • src\..\
  • src\..\


  • Sprite
  • Image
  • GestureProvider
  • GestureProviderImpl
  • AccelerationProvider
  • AccelerationProviderImpl
  1. Design considerations

There is a Timer that schedules three TimerTasks that are run with different frequencies. One of them handles coordinate updating and rendering, second handles car turning, and third updates forces and frictions.

The track images have a limited resolution because the bigger the image resolution, the more memory it requires. All three tracks are 600x600 pixels. The Gesture and Sensor APIs are used in a way that the game does not crash if the device does not support them. The needed Gesture and Acceleration classes are wrapped with classes GestureProvider and AccelerationProvider.

  1. Known issues

Engine sound has been removed in version 1.2. Engine sound is possible to run without the control, but then the sound is poor quality monotone sound.

  1. Build and installation instructions

The example has been made with NetBeans 7.1 and Nokia SDK 2.0. The project can be easily opened in NetBeans by selecting Open Project from the File menu and selecting the application. Add the following key-value pair to the JAD file:

Before opening the project, make sure the Nokia SDK 2.0 or newer is installed and added to NetBeans. Building is done by selecting Build main project.

Installing the application on a phone can be done by transfering the JAR file via Nokia Ovi Suite or via Bluetooth.

The application can also be run with Nokia IDE.

  1. Running the example

From the Start menu, the user can start the game, change the track from settings, and exit the game. The game view starts with a countdown 3-2-1-Go, and then the game begins.

If you are using a Nokia Asha software platform or Series 40 full touch device, the car is turned by tilting the device. To brake, press the brake button in the bottom-left corner. If the user does not allow the sensor use
(selects 'No' in the security prompt), the game falls back to using gestures.

If you are using a Series 40 touch and type device, the car is turned by dragging finger to the left and right. To brake, press 7 key.

The game can also be played on a Series 40 non-touch phone using the number keys. However, note that the game has primarily been developed and optimised for newer touch devices.

If you drive off the road, the car will go slower.

The speedometer is in the bottom-right corner of the screen. The top bar displays the lap time, best lap time, and amount of laps driven.

There is a Menu button in the top-left corner of the screen. Pressing the Menu button ends the game and returns you back to the main menu.

In the settings, you can choose between three different tracks.

  1. Compatibility

Nokia Asha software platform and Series 40 6th Edition, FP1 devices and newer Series 40 phones.

Tested on Nokia Asha 501, Nokia Asha 311, Nokia Asha 308, Nokia Asha 305, Nokia Asha 303 and Nokia X3-02.

Developed with Nokia Asha SDK 1.0.

  1. Version history

  • 1.3 Implemented fallback to gestures when sensor prompt is declined. Fixed support for Series 40 non-touch devices.
  • 1.2 Ported to Nokia Asha software platform 1.0.
  • 1.1 Runs now also on Fulltouch phones. Updated appearance and tracks. Gates are now visible. Optimized for slower phones.
  • 1.0 First release