android - Speed up bitmap animation in custom View -


in custom view have 1 animation need run @ demand (on tile click). using method:

 public boolean ontouchevent(motionevent event) {             switch(event.getaction()){              case motionevent.action_down:     //check tile clicked                     gethandler().removecallbacks(explosionthread);                      gethandler().post(explosionthread);                     }                  }             break;         }         return super.ontouchevent(event);      } 

so calling (or sending view thread, specific) runnable calls self until comes end of image...

private runnable explosionthread=new runnable(){         @override         public void run() {             invalidate();             if(expcount<15){             gethandler().postdelayed(this, 10);             }         }        }; 

in ondraw() method implemented logic go threw bitmap , draw on screen ( using cnavas.drawbitmap(bitmap,srcrect,destrect,paint)....

now, want avoid using surfaceview (i have 1 animation , view uses less resources). think animation slow because ondraw needs draw whole screen each time invalidate() called witch can slow ( drawing 64 tiles png images). know there overload of invalidate method, invalidate(rect dirty) don't know how use it. if u think that answer please write how avoid drawing whole ondraw method ( or method can overwrite used invalidate(rect) method, if there any).

if have other better way speed animation post plz. in advance....

that's right. 1 of way speed rendering through canvas use invalidate(rect). rect passed invalidate method defines area redrawn. ondraw called after invalidate clipping region being set on canvas. "drawbitmap" clipped rect.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -