Why won't my layers appear when I try to load an image with J2ME?
I'm trying to load an image. The program compiles but the layers don't appear.
These are the errors I get:
开发者_JAVA技巧TRACE: , startApp threw an Exception
java.lang.IllegalArgumentExceptionat javax.microedition.lcdui.game.TiledLayer.(), bci=66
at RRCanvas.start(RRCanvas.java:32) at RRashlMIDlet.startApp(RRashlMIDlet.java:16)
and this is the code on those lines:
try {
trackLayer = new TiledLayer(12, 48, Image.createImage("/map.png"), 48, 48);
grassLayer = new TiledLayer(12, 48, Image.createImage("/map.png"), 48, 48);
checkpointLayer = new TiledLayer(12 , 48, Image.createImage("/map.png"), 48, 48);
}
catch (IOException e) {
System.err.println("Failed loading images!");
}
and
canvas.start();
The exception is being thrown in the TiledLayer constructor. Here is the documentation for that constructor. Have a look at the possible reasons why that exception might be thrown, and use the debugger to find out if the arguments to any of the constructor calls have those problems.
精彩评论