Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ahbab Alam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic