I got a problem im trying to make a java game in an applet.
I can't load more then 1 image, otherwise it will not load.
I am getting the images of the jar file.
Code loader:
public BufferedImage LoadTex(String ura) {
BufferedImage res = null;
try {
URL url = this.getClass().getClassLoader().getResource("tex/" + ura);
res = ImageIO.read(url);
} catch (IOException e) {
}
return res;
}
Code applet:
tex texu = new tex();
BufferedImage plr;
BufferedImage hud_right;
BufferedImage hud_bottom;
@Override
public void init() {
plr = texu.LoadTex("tspr.png");
hud_right = texu.LoadTex("hud_right.png");
hud_bottom = texu.LoadTex("hud_bottom.png");
}
@Override
public void paint(Graphics screen) {
Graphics2D G2D = (Graphics2D) screen;
G2D.drawImage(hud_right, 570, 0, null);
G2D.drawImage(hud_bottom, 0, 410, null);
}
It works perfect with 1 image but if i try more it stops. And client wont even load.
It's giving the error: input == null
How to fix this.
Thank you