Hi!
I am making my own “game” to test my skills 8).
Now i am making the HUD and I am using UIOverlay to paint it.
The only problem for now is that the clearRect(x, y, width, height) (which is removing all previous graphics) is very slowly.
How to do it faster?
Here is the code:
public void paint(Graphics2D poGraphics2D) {
// Clear All Previous
poGraphics2D.setBackground(moTransparent);
// This is slow
poGraphics2D.clearRect(0, 0, width, height);
// Test Drawing
poGraphics2D.setColor(Color.WHITE);
poGraphics2D.drawString("" + System.currentTimeMillis(), poGraphics2D.getFontMetrics().getMaxAscent(), height - poGraphics2D.getFontMetrics().getMaxAscent());
// FPS
poGraphics2D.setColor(Color.WHITE);
poGraphics2D.drawString("FPS : " + miFPS, poGraphics2D.getFontMetrics().getMaxAscent(), height - poGraphics2D.getFontMetrics().getMaxAscent() * 2);
// Transparency
poGraphics2D.setComposite(moComposite);
// Cross-Hair
poGraphics2D.setColor(moCrossHairColor);
poGraphics2D.fillOval(639, 511, 2, 2);
poGraphics2D.drawLine(620, 510, 638, 492);
poGraphics2D.drawLine(620, 514, 638, 532);
poGraphics2D.drawLine(660, 510, 642, 492);
poGraphics2D.drawLine(660, 514, 642, 532);
// Radar
poGraphics2D.setColor(Color.BLACK);
poGraphics2D.drawOval(5, 5, 200, 200);
poGraphics2D.setColor(Color.GREEN);
poGraphics2D.fillOval(5, 5, 200, 200);
poGraphics2D.setColor(Color.WHITE);
poGraphics2D.fillRect(104, 5, 2, 105);
}
If someone have got anything please reply!
Thanks