I'm using getSubImage() to get a BufferedImage area of an image and it draws it very slowly, here's what I'm doing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| BufferedImage sprites = null; try { sprites = ImageIO.read(getClass().getResource("sprites.gif")); } catch (IOException e1) { e1.printStackTrace(); }
BufferedImage badGuy = sprites.getSubimage(82,0,19,25); BufferedImage goodGuy = sprites.getSubimage(56,0,26,13); BufferedImage bullet = sprites.getSubimage(41,25,16,5); BufferedImage explosion = sprites.getSubimage(0,0,32,31);
...
... ... g.drawImage(...); |
pretty straight forward, but the framerate drops down to 1 fps, how can I speed things up, or accomplish what I'm trying to do in a different way?