Use is subject to License Terms. Your use of this web site or any of its contents or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. and Motorola, Inc. All rights reserved.

MID Profile

Package javax.microedition.lcdui.game

The Game API package provides a series of classes that enable the development of rich gaming content for wireless devices.

See:
          Description

Class Summary
GameCanvas The GameCanvas class provides the basis for a game user interface.
Layer A Layer is an abstract class representing a visual element of a game.
LayerManager The LayerManager manages a series of Layers.
Sprite A Sprite is a basic visual element that can be rendered with one of several frames stored in an Image; different frames can be shown to animate the Sprite.
TiledLayer A TiledLayer is a visual element composed of a grid of cells that can be filled with a set of tile images.
 

Package javax.microedition.lcdui.game Description

The Game API package provides a series of classes that enable the development of rich gaming content for wireless devices.

Wireless devices have minimal processing power, so much of the API is intended to improve performance by minimizing the amount of work done in Java; this approach also has the added benefit of reducing application size.  The API's are structured to provide considerable freedom when implementing them, thereby permitting the extensive use of native code, hardware acceleration and device-specific image data formats as needed.

The API uses the standard low-level graphics classes from MIDP (Graphics, Image, etc.) so that the high-level Game API classes can be used in conjunction with graphics primitives.  For example, it would be possible to render a complex background using the Game API and then render something on top of it using graphics primitives such as drawLine, etc.

Methods that modify the state of Layer, LayerManager, Sprite, and TiledLayer objects generally do not have any immediately visible side effects. Instead, this state is merely stored within the object and is used during subsequent calls to the paint() method. This approach is suitable for gaming applications where there is a game cycle within which objects' states are updated, and where the entire screen is redrawn at the end of every game cycle.

API Overview

The API is comprised of five classes:

GameCanvas

This class is a subclass of LCDUI's Canvas and provides the basic 'screen' functionality for a game.  In addition to the methods inherited from Canvas, this class also provides game-centric features such the ability to query the current state of the game keys and synchronous graphics flushing; these features simplify game development and improve performance.

Layer

The Layer class represents a visual element in a game such as a Sprite or a TiledLayer.  This abstract class forms the basis for the Layer framework and provides basic attributes such as location, size, and visibility.

LayerManager

For games that employ several Layers, the LayerManager simplifies game development by automating the rendering process.  It allows the developer set a view window that represents the user's view of the game.  The LayerManager automatically renders the game's Layers to implement the desired view.

Sprite

A Sprite is basic animated Layer that can display one of several graphical frames.  The frames are all of equal size and are provided by a single Image object.  In addition to animating the frames sequentially, a custom sequence can also be set to animation the frames in an arbitrary manner.  The Sprite class also provides various transformations (flip and rotation) and collision detection methods that simplify the implementation of a game's logic.

TiledLayer

This class enables a developer to create large areas of graphical content without the resource usage that a large Image object would require.  It is a comprised of a grid of cells, and each cell can display one of several tiles that are provided by a single Image object.  Cells can also be filled with animated tiles whose corresponding pixel data can be changed very rapidly; this feature is very useful for animating large groups of cells such as areas of water.
 

@since MIDP 2.0
 


MID Profile

Copyright © 2006 Sun Microsystems, Inc. and Motorola, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 118 specification.