ok, i’m using Ktoolbar to build the game, then running it from the command line with midp -classpath . filename
[i don’t have net access at home, so the RUN button just doesn’t work]
I’ve built the Jad and .Jar files and the splash.png is included.
yet no matter where i place the image file [in the rec or src folders, it matters not] i still get the IO Exception
For the sake of it, this is the Splash.java code i’m using
import javax.microedition.lcdui.*;
public class splash extends Canvas implements Runnable
{
private boolean running = true;
private Image osb;
private Graphics osg;
private Blockade theMidlet;
private int starFieldViewY;
private Image title;
private int fontHeight;
private Font font;
private String filename;
public splash(Blockade midlet)
{
theMidlet = midlet;
initResources();
// create the timer thread
Thread t = new Thread(this);
t.start();
}
private void initResources()
{
// setup the screen
try
{
osb = Image.createImage(getWidth(), getHeight());
osg = osb.getGraphics();
filename = "/splash.png";
title = Image.createImage(filename);
font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
fontHeight = font.getHeight() + 2;
osg.setFont(font);
}
catch(Exception e)
{
System.out.println("can't load file: " + filename + " why? ==> " + e);
e.printStackTrace();
}
}
private static final int MAX_CPS = 100;
private static final int MS_PER_FRAME = 1000 / MAX_CPS;
public void run()
{
try
{
while (running)
{
// remember the starting time
long cycleStartTime = System.currentTimeMillis();
// do our work
repaint();
// sleep if we've finished our work early
long timeSinceStart = (cycleStartTime - System.currentTimeMillis());
if (timeSinceStart < MS_PER_FRAME)
{
try
{
Thread.sleep(MS_PER_FRAME - timeSinceStart);
}
catch (java.lang.InterruptedException e)
{
}
}
}
// fall back to the splash form at the end of our loop
theMidlet.activateMenu();
}
catch (Exception e)
{
System.out.println("App exception2: " + e);
e.printStackTrace();
}
}
private void renderSplash()
{
// clear the background
osg.setColor(0);
osg.fillRect(0, 0, getWidth(), getHeight());
osg.drawImage(title, getWidth() / 2, getHeight() / 2 - 10, Graphics.HCENTER | Graphics.VCENTER);
// draw text
osg.setColor(0x00888888);
osg.drawString("© 2005", getWidth() / 2, getHeight() - fontHeight * 3,
Graphics.HCENTER | Graphics.TOP);
osg.drawString(" Crontastic Production", getWidth() / 2, getHeight() - fontHeight * 2,
Graphics.HCENTER | Graphics.TOP);
// draw the copy line
osg.setColor(0x00ffffff);
osg.drawString("Press Any Key", getWidth() / 2, getHeight() - fontHeight * 1,
Graphics.HCENTER | Graphics.TOP);
}
protected void paint(Graphics graphics)
{
renderSplash();
graphics.drawImage(osb, 0, 0, Graphics.LEFT | Graphics.TOP);
}
protected void keyPressed(int keyCode)
{
running = false;
}
}