Java Reference
In-Depth Information
Wrapping Up
MIDP 2.0 contains the Mobile Game API in javax.microedition.lcdui.game , a robust set of
classes you can use to implement your own games. This interface consists of five classes:
GameCanvas : Lets you poll for keystrokes and structure your game around the notion
of a game loop using Java threads
LayerManager : Responsible for managing visible elements on the screen in a Z-order
you define and draw
Layer : Represents a single plane in the Z-order
TiledLayer : An implementation of Layer you can use to create large bitmap images
from small tiles
Sprite : An implementation of Layer you can use to create animations
Using the Mobile Game API, you structure your game MIDlet around the notion
of a game loop that runs in its own thread, managing events and updating game state.
Your game loop can poll for keystrokes or respond to events in the traditional manner,
and it draws to the screen as it needs to using the GameCanvas 's Graphics context. The
LayerManager class simplifies drawing by managing an array of Layer s, which each can
paint their own contents. The API defines two specific kinds of layers: the TiledLayer ,
which is suitable for drawing large regions of a game such as the game level's back-
ground, and the Sprite , which helps you organize the frames of an animation for a
specific visible object.
 
Search WWH ::




Custom Search