scroll3d.java

来自「这是一个用2D来模拟3D效果的卷轴动画 希望大家喜欢!」· Java 代码 · 共 54 行

JAVA
54
字号
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.
 *
 * This code is part of the Tips & Tricks section at 
 * www.SonyEricsson.com/developer
 *
 * Written by J鰊s Weimarck, 2004
 */
public class Scroll3D 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() {}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?