Hi,
I’m having the following strange problem (sometimes it works sometimes not).
Every tile of my map is prerendered at the beginning of the game:
private void prerender(int iTile) {
BufferedImage renderedTile = mGfxConfig.createCompatibleImage(Tile.WIDTH, Tile.HEIGHT, Transparency.BITMASK);
Graphics2D g2D = renderedTile.createGraphics();
g2D.drawImage((Image) mTileImages.get("plain"), 0, 0, null);
//...
mRenderedTiles.put(new Integer(iTile), renderedTile);
g2D.dispose();
}
Ok. Here’s the method putTile which is called by the main render loop:
public void putTile(Graphics g, int x, int y, int iTile) {
if(!mRenderedTiles.containsKey(new Integer(iTile)))
prerender(iTile);
g.drawImage((BufferedImage) mRenderedTiles.get(new Integer(iTile)), x, y, null);
}
Ok, now the problem is: sometimes it works but often it doesn’t. Sometimes mRenderedTiles contains just empty images with nothing painted on.
What could be the problem?