1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| import java.io.IOException;
import javax.microedition.lcdui.game.TiledLayer;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.Object;
import javax.microedition.lcdui.game.Layer;
import javax.microedition.io.*;
/**
*
* @author Omegasf3
* @version
*/
public class Sprite1 extends MIDlet implements CommandListener {
private Command ExitCommand;
private Display display;
private Form form;
private Form pageDemo() {
Image myImage1 = null;
Form mainpage = new Form("Demo Images");
try {
System.out.println("phase 0");
Image myImage1Src = Image.createImage("/example/Image/bloc.png");
TiledLayer tl = new TiledLayer(10, 10, myImage1Src, 16, 16);
int [] map = {
1,1,1,1,1,1,1,1,1,1,
1,1,6,0,0,0,0,5,1,1,
1,6,0,0,0,0,0,0,5,1,
1,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,1,
1,8,0,0,0,0,0,0,7,1,
1,1,8,0,0,0,0,7,1,1,
1,1,1,1,1,1,1,1,1,1
};
for(int i = 0; i <map.length; i++) {
int column = i%10;
int line = (i -column) /10;
tl.setCell(column, line, map[i]);
}
//System.out.println("phase 1");
//myImage1 = Image.createImage(myImage1Src,0,0,176,155,0);
//System.out.println("phase 2");
//System.out.println("phase 3");
//g.drawImage(myImage1Src, 0, 0, TOP|LEFT);
//g.drawImage(myImage1Src, 0, 0, TOP|LEFT);
} catch (IOException e) {
e.printStackTrace();
}
mainpage.append(myImage1);
return mainpage;
}
public Sprite1() throws IOException {
Command ExitCommmand;
display = Display.getDisplay(this);
form = pageDemo();
ExitCommmand = new Command("EXIT", Command.EXIT, 1);
form.addCommand(ExitCommand);
form.setCommandListener(this);
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable) {
if(command == ExitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
} |
Partager