Before you start
The latest Mobile Information Device Profile (MIDP) 2.0 for J2ME (Java 2 Platform, Micro Edition) added support for sprites -- images with additional attributes and methods to facilitate animation, transformation (rotate, flip and mirror), and collision detection. In this tutorial you'll explore the differences between nonanimated and animated sprites, learn about sprites placement using a reference pixel, and discuss how to detect collisions between sprites.
During the course of this tutorial you'll create two MIDlets (J2ME applications). The first will demonstrate how to create and display an animated sprite, whereas the second will be a simple game that illustrates collision detection in action.
Once you've completed this tutorial, you'll have a base knowledge from which to begin incorporating sprites into your J2ME applications.
You'll need two software tools to complete this tutorial:
- The Java Development Kit (JDK): The JDK provides the Java source code compiler and a utility to create Java Archive (JAR) files. When working with the Wireless Toolkit 2.0 (as you will be here), you'll need to download JDK version 1.4 or greater. Download JDK version 1.4.1.
- The Wireless Toolkit (WTK): The Sun Microsystems Wireless Toolkit integrated development environment (IDE) creates J2ME MIDlets. The WTK download contains an IDE, as well as the libraries required for creating MIDlets. Download J2ME Wireless Toolkit 2.0.
The Java Development Kit (JDK)
Use the JDK documentation to install the JDK. You can choose either the default directory or specify another directory. If you choose to specify a directory, make a note of where you install the JDK. During the installation process for the Wireless Toolkit, the software attempts to locate the Java Virtual Machine (JVM); if it cannot locate the JVM, you are prompted for the JDK installation path.
This tutorial builds on an earlier developerWorks tutorial "MIDlet Development with the Wireless Toolkit" (see Resources), which explains the basics of creating MIDlets with the toolkit. This tutorial is an excellent starting point if you are new to the Wireless Toolkit.
The Wireless Toolkit is contained within a single executable file. Run this file to begin the installation process. It is recommended that you use the default installation directory. However, if you do not use the default directory, make sure the path you select does not include any spaces.




