aspose file tools*
The moose likes Android and the fly likes Previous image does not clear on repainting Canvas in a loop with different positions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Previous image does not clear on repainting Canvas in a loop with different positions" Watch "Previous image does not clear on repainting Canvas in a loop with different positions" New topic
Author

Previous image does not clear on repainting Canvas in a loop with different positions

Ahbab Alam
Greenhorn

Joined: Mar 03, 2012
Posts: 1
Hi All,
I am new to android and trying to animate small image.
I have written below piece of code but during execution i see the the traces of previous drawn images



this method is invoked from another thread:



Do you guys see anything wrong in this ? Any comment will be appreciated.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Unless you are dealing with sprites , you have to erase the first image before painting the second image. If your background is a solid color, to erase an image, repaint the exact same image using the background color. Then paint the new image.


JBoss In Action
Przemek Boryka
Ranch Hand

Joined: Dec 06, 2011
Posts: 51

Hi!

I think you can do it in one thread, call him animatThread, for example : animateUpdate(), animateRender(), paintScreen() methods invoked from thread. All those metods should be in while loop for example:

... animateThread ...



this piece of code is from Java, but I think that, the mechanism will be the same both in Java and Android. Maybe this will help you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Previous image does not clear on repainting Canvas in a loop with different positions
 
Similar Threads
How does canvas, an exteded JPanel obj have methods getSize(), createImage(size.width, size.height)?
Image from Canvas
how to get Image from Canvas
Still not working..help please.
[Solved] Clear SurfaceView