LogoCanvas.java
上传用户:pyly5030
上传日期:2021-09-17
资源大小:174k
文件大小:2k
- import javax.microedition.lcdui.*;
- public class LogoCanvas extends Canvas implements Runnable{
- private GameCanvasMidlet midlet;
- private Display display;
- private boolean islogo = true;
- private int status = 0;
- int count = 0;
-
- public LogoCanvas(GameCanvasMidlet midlet){
- this.midlet = midlet;
- Thread thread = new Thread(this);
- thread.start();
- }
-
- protected void paint(Graphics g) {
- try{
- switch (status) {
- case 0:
- g.setColor(0x00FFFFFF);
- g.fillRect(0, 0, getWidth(), getHeight());
- g.setColor(0x0000000);
- Image logoImage;
- logoImage = Image.createImage("/logo.png");
- g.drawImage(logoImage, getWidth()/2, getHeight()/2, 3);
- break;
- case 1:
- g.setColor(0x0000000);
- g.fillRect(0, 0, getWidth(), getHeight());
- Image nbImage = Image.createImage("/nb.jpg");
- g.drawImage(nbImage, getWidth()/2, getHeight()/2, 3);
- break;
- case 2:
- islogo = false;
- //MyGameCanvas canvas = new MyGameCanvas();
- MenuCanvas canvas = new MenuCanvas(midlet);
- canvas.setFullScreenMode(true);
- //canvas.start();
- display = Display.getDisplay(midlet);
- display.setCurrent(canvas);
- break;
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- public void run() {
- while (islogo) {
- if (status == 0) {
- // 移动logo
- if (count == 30) {
- count = 0;
- status = 1;
- repaint();
- } else {
- count++;
- }
- } else if (status == 1) {
- // sp Logo
- if (count == 30) {
- status = 2;
- count = 0;
- repaint();
- } else
- count++;
- }
- try {
- Thread.sleep(15L);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
- }