Layer Manager

A single screen can show multiple layers. For example, in Push Puzzle, the pusher is a simple tile, but it could be a sprite. If the pusher were a sprite, the screen would be made up of two layers: the background and the sprite. The game package includes a layer manager, which draws the individual layers onto the device screen.

Layer Ordering

The layer manager keeps the layers in an ordered list, and assigns the layers contiguous integers. The app developer can add and remove layers from the list. Layer zero is closest to the top; higher numbers are progressively further away.

MIDP Implementors

Strongly Recommend: Java graphics bulb1_icon.gif If the app developer removes a layer from the middle of the list, renumber the remaining layers to keep them contiguous.

Strongly Recommend: Java graphics bulb1_icon.gif Draw the layers onto the screen in order, beginning with the layers furthest from the user (the backgrounds) through the layer closest to the user (layer zero).

app Developers

Strongly Recommend: Java graphics bulb1_icon.gif Remember, when you use the layer manager, the order of your layers is important.

The View Window and Panning

The layer manager has a view window, which enables the app developer to choose which part of the layer is shown to the user. The ability to show only one part of a layer to the user at a time enables the app to use background panning. Screenshot shows a game canvas using the view window; the user can see only part of the layer. The full canvas is shown in Screenshot, level two.

Screenshot View Window Showing Part of a Game Canvas

Java graphics 11fig06.gif


app Developers

Strongly Recommend: Java graphics bulb1_icon.gif As you consider whether to use panning, keep the input mechanism of the device in mind. A phone with a joystick-style disk is easier for users to pan with than a phone with only a keypad.

Strongly Recommend: Java graphics bulb1_icon.gif If you use a view window, make it as large as or smaller than the screen area being used. A view window that is larger than the visible screen may result in a computation that will not be used if the view window's content must be clipped to fit on the screen.

Strongly Recommend: Java graphics bulb1_icon.gif If you use a view window, keep the size of the display and the size of the image you are panning in proportion. A large image on a small display could be annoying to pan in certain games, especially those in which the user is expected to move quickly around the display. A large image on a small display could also be a problem in games that involve remembering the layout of the display. The game in Screenshot is such a game. Users can easily lose the game if they forget the layout of walls. Forgetting is easier if most of the image is out of sight.



   
Comments