Using Playfield - Motorola C370 Series Technical Manual

J2me developer guide
Hide thumbs Also See for C370 Series:
Table of Contents

Advertisement

public void setViewWindow(int x, int y, int width,
int height) – Sets the portion of the PlayField that will be drawn when
draw(Graphics, int, int) is called. This will limit the portion of the PlayField that is
drawn to the rectangle defined by the region
height)
PlayField, i.e. the rectangular region bounded by
getCellWidth()
by the parameters may extend beyond the bounds of the PlayField. If this happens,
the
the grid boundaries. Sprites may still be drawn in this area if their position places
them outside the bounds of the PlayField grid. The view window stays in effect until it
is modified by another call to this method or is reset as a result of calling
setStaticTileSet(Image, int, int). The method parameters are
pixel for the drawing view window,
window,
drawing view window.

Using PlayField

The following is a code sample to show implementation of
PlayField
// Creates a playField with 100 columns and 10
// rows and tiles with 24x16 pixels
PlayField foreground = new PlayField(100, 10,
Image.createImage("tiles.png"), 24, 16);
// Sets the first cell in the first line to
// empty(tile with index 0)
foreground.setCell(0, 0, 0);
// Fills the second cell in the first line with tile 1
foreground.setCell(1, 0, 1);
// Fills the third cell in the first line with tile 2
foreground.setCell(2, 0, 2);
// Fills the fourth cell in the first line with tile 3
foreground.setCell(3, 0, 3);
// Gets the Graphics object for this GameScreen
Graphics g = getGraphics();
// Draws the foreground playfield
foreground.draw(g, 0, 0);
. The default view window (at construction time) is the entire area of the
getGridHeight()
,
draw(graphics, int, int)
- width of the drawing view window, and
width
to
(x, y)
(x + width, y +
(0, 0)
* getCellHeight())
method will draw no tiles in the area outside
- y coord of top-left pixel for the drawing view
y
height
PlayField
and (getGridWidth()
*
.The rectangle defined
- x coord of top-left
x
- height of the
:

Advertisement

Table of Contents
loading

This manual is also suitable for:

C450 seriesC550 series

Table of Contents