input();
drawScreen(g);
try
{
Thread.sleep(delay);
} catch (InterruptedException ie)
{
}
}
}
// Method to Handle User Inputs
private void input()
{
int keyStates = getKeyStates();
if ((keyStates & LEFT_PRESSED) != 0)
{
if (scnX - 1 > 0)
scnX--;
}
if ((keyStates & RIGHT_PRESSED) != 0)
{
if (scnX + 1 + 140 < backgroundImage.getWidth())
scnX++;
}
}
// Method to Display Graphics
private void drawScreen(Graphics g)
{
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x0000ff);
// display all layers
layerManager.setViewWindow(scnX, scnY, 140, 140);
layerManager.paint(g, 20, 20);
flushGraphics();
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SimpleScrollingLayerManger extends MIDlet
{
private Display display;
public void startApp()
{
try
{
display = Display.getDisplay(this);
ExampleGameCanvas gameCanvas = new ExampleGameCanvas();
gameCanvas.start();
display.setCurrent(gameCanvas);
} catch (Exception ex)
{
System.out.println(ex);
}
}
public Display getDisplay()
{
return display;
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
exit();
}
public void exit()
{
System.gc();
destroyApp(false);
notifyDestroyed();
}
}