DoubleBackgroundDemo.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- import java.io.IOException;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.MIDlet;
- /**
- * Shows how to use two Layers of background moving at different speed,
- * to create a sense of 3D.
- */
- public class DoubleBackgroundDemo extends MIDlet implements CommandListener {
- private Display display;
- private ScrollCanvas scrollCanvas;
- private Command exitCommand;
- public void startApp() {
- try {
- scrollCanvas = new ScrollCanvas();
- exitCommand = new Command("Exit", Command.EXIT, 0);
- scrollCanvas.addCommand(exitCommand);
- scrollCanvas.setCommandListener(this);
- display = Display.getDisplay(this);
- display.setCurrent(scrollCanvas);
- scrollCanvas.start();
- }catch (IOException ioe) {
- System.out.println(ioe.getMessage());
- }
- }
- public void commandAction(Command c, Displayable d) {
- if (c.getCommandType() == Command.EXIT) {
- destroyApp(true);
- notifyDestroyed();
- }
- }
- public void destroyApp(boolean unconditional) {
- scrollCanvas.stop();
- }
- public void pauseApp() {}
- }