Layers

I need to update things on the screen while keeping a background image intact. At the moment I am repainting the foreground and background, but I know there has to be a better way!

Graphics2D g2d = (Graphics2D)g;

g2d.setPaint(mapPaint);//set image to paint

g2d.fill(mapRect);//lay down background

updateDisplay(g2d);//update foreground and lay it on top

the trouble I am having is clearing the trail left on the foreground without redrawing the background.

CaseyB

[506 byte] By [Caseyba] at [2007-10-1 16:22:23]
# 1
Ok, ignore this! Sprites are the ticket and Woogley has posted a WONDERFUL example in another thread!
Caseyba at 2007-7-11 0:35:35 > top of Java-index,Other Topics,Java Game Development...
# 2
I'm glad you found it helpful :) http://woogley.net/misc/LayerExample for those who are curious about it
Woogleya at 2007-7-11 0:35:35 > top of Java-index,Other Topics,Java Game Development...
# 3
This dramatically increased the performance with a small number of sprites (i.e 300) but as I increased the number the performance dropped dramatically! Is there a way to use hardware acceleration with 2D Primitives?
Caseyba at 2007-7-11 0:35:35 > top of Java-index,Other Topics,Java Game Development...
# 4
> Is there a way to use hardware acceleration with 2D> Primitives?Check out the VolatileImage API
SoulTech2012a at 2007-7-11 0:35:35 > top of Java-index,Other Topics,Java Game Development...