请教大侠一个空指针问题
我建立了两个类一起的分别是gameStarat()和myCanvas();做一个8*8的空格 但运行时出现了空指针异常请帮帮小弟 谢谢!!!
package SaoLei;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class gameStart extends MIDlet {
public static gameStart midlet;
public myCanvas mc;
public gameStart() {
gameStart.midlet=this;//全局入口对象
}
protected void startApp() throws MIDletStateChangeException {
gameStart.midlet.startGame();
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
public void startGame(){
mc=null;
mc=new myCanvas();
Display.getDisplay(this).setCurrent(mc);
}
public void exitGame(){
this.notifyDestroyed();
}
}
package SaoLei;
import java.util.Random;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class myCanvas extends Canvas{
public Image offScreen;
public Graphics offg;
public Random r1;
public Image imCircle,immine;
public int map[][]=new int[8][8];
public int mineNumber=10;
public myCanvas(){
r1=new Random();
offScreen=Image.createImage(176,208);
offg=offScreen.getGraphics();
initMap();
try{ imCircle.createImage("/cricle.png");
immine.createImage("/mine.png");
}catch (Exception e) {
}
}
private void initMap() {
for (int n=0;n<mineNumber;n++) {
int tmp=Math.abs(r1.nextInt()%64);
int row=tmp/8;
int col=tmp%8;
if(map[row][col]!=20){
map[row][col]=20;
}else{
n--;
}
}
}
public void drawMap(){
offg.setColor(0xFFFFFF);
offg.fillRect(0,0,176,208);
offg.setColor(0);
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
offg.drawRect(j*20,i*20,20,20);
}
}
}
public void drawCricle(){
offg.drawImage(imCircle,0,0,0);
}
protected void paint(Graphics g) {
drawMap();
drawCricle();
g.drawImage(offScreen,0,0,0);
}
}