thanks alot shmoove

after posting my question i found a similar solution, but the animation still looks choppy

description of what my app does:
(i didn't know that some devices are auto-double-buffered so i'll add code to handle that as well now - thanks

)
first i clear the virtual buffer image.
I draw some image to the virtual buffer image.
I draw a rectangle and in it some text to the virtual buffer image.
i draw the virtual buffer image into the real device screen.
the rectangle that has text in it is controlled with the keys of the mobile.
for some reason, the rectangle+text leaves some sort of a trail, and looks VERY choppy when running the app on my device (nokia 3100).
any idea of what might be the cause?
here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public void paint(Graphics g) { if (!bInitedGraphicsSize) initBackBuffer(g); backBufferGraphics.setColor(0xffffff); backBufferGraphics.fillRect(CORNER_X, CORNER_Y, DISP_WIDTH, DISP_HEIGHT); Font dFont = backBufferGraphics.getFont(); int fontH = dFont.getHeight(); int fontW = dFont.stringWidth("Devour!"); backBufferGraphics.setColor(0xff0000); backBufferGraphics.fillRect((DISP_WIDTH-fontW)/2 - 1 + iTextPosX, (DISP_HEIGHT-fontH)/2 + iTextPosY, fontW + 2, fontH); backBufferGraphics.setColor(0x00ff00); backBufferGraphics.setFont(dFont); backBufferGraphics.drawString("Devour!", (DISP_WIDTH-fontW)/2 + iTextPosX, (DISP_HEIGHT-fontH)/2 + iTextPosY, g.TOP|g.LEFT);
player.paint(backBufferGraphics); g.drawImage(backBufferImage, 0,0, g.TOP|g.LEFT); } |
Edit:
ok, i changed my code (now it's more similar to yours, and handles both cases)
i tested and found that the device i'm testing (nokia 3100) has double buffering... :/
prehaps the reason is different.