Got the left and right scroller working with MIDP 1.0, so I thought that I would post the code for others:
Code:
public final static int COLUMN_WIDTH = 8;
private int num_columns = (width + (COLUMN_WIDTH - 1)) * COLUMN_WIDTH;
public void GAME_ProcessScroller()
{
Graphics g2 = offScreenBuffer.getGraphics();
int t, sx, sy = 0, dx, dy = 0;
if (nXScroll != 0)
{
int step_x;
if (nXScroll > 0) // Scroll right
{
sx = num_columns * COLUMN_WIDTH;
dx = COLUMN_WIDTH;
step_x = -COLUMN_WIDTH;
}
else // Scroll left
{
sx = 0;
dx = -COLUMN_WIDTH;
step_x = COLUMN_WIDTH;
}
for (t = 0; t < num_columns; t++)
{
g2.setClip(sx, sy, COLUMN_WIDTH, height);
g2.drawImage(offScreenBuffer, dx, dy, Graphics.LEFT | Graphics.TOP);
sx += step_x;
}
}
}
Note that this only scrolls an image left / right, to turn this into a full scroller you will need to draw columns of new tiles to fill in the space. If anyone can do this quicker then please let me know.