/Files/SCUTMSC/mobileGame.pptx
上面的是ppt
通用的MIDlet类
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;
/**
* @author user
*/
public class Midlet extends MIDlet implements CommandListener{
private JCanvas canvas;
public void startApp() {
if(canvas==null){
canvas=new JCanvas(Display.getDisplay(this));
Command exitCommand = new Command("Exit", Command.EXIT, 0);
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
canvas.start();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c.getCommandType() == Command.EXIT) {
destroyApp(true);
notifyDestroyed();
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;
/**
* @author user
*/
public class Midlet extends MIDlet implements CommandListener{
private JCanvas canvas;
public void startApp() {
if(canvas==null){
canvas=new JCanvas(Display.getDisplay(this));
Command exitCommand = new Command("Exit", Command.EXIT, 0);
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
canvas.start();
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c.getCommandType() == Command.EXIT) {
destroyApp(true);
notifyDestroyed();
}
}
}
画“囧”
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
public class JCanvas extends Canvas{
private Display display;
public JCanvas(Display d){
display=d;
display.setCurrent(this);
}
public void start(){
repaint();
}
protected void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, getHeight(), getWidth());
g.setColor(0, 0, 0);
g.drawRect(70, 80, 100, 100);
g.drawArc(70, 85, 30, 25, 270, 90);
g.drawArc(140, 85, 30, 25, 180, 90);
g.drawRect(104, 150, 32, 30);
}
}
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
public class JCanvas extends Canvas{
private Display display;
public JCanvas(Display d){
display=d;
display.setCurrent(this);
}
public void start(){
repaint();
}
protected void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, getHeight(), getWidth());
g.setColor(0, 0, 0);
g.drawRect(70, 80, 100, 100);
g.drawArc(70, 85, 30, 25, 270, 90);
g.drawArc(140, 85, 30, 25, 180, 90);
g.drawRect(104, 150, 32, 30);
}
}