Sprite movement with Android Canvas very slow -


okay, i've been working on simple game in android using canvas , threading. (i extend surfaceview , implement runnable).

the code run loop is:

@override public void run()  {     while(running)     {         synchronized(holder)         {             if(!holder.getsurface().isvalid())             {                 continue;             }//end if isvalid() call               update();             draw();          }     }//end while  }//end run() 

what if want have sprite move , forth across screen quickly? if have sprite's "speed" set 1, move 1 pixel each update. if it's updating @ 20 or 30 fps, means sprite (in case 100 x 80 px sprite) going move 20 or 30 pixels every second. there way make move faster?

here's dilemma:

if change "speed" of sprite 5, example - sounds great right? move 5 pixels every update. jittery - there no smooth movement between draw() calls, because it's hopping 5 pixels each time.

surely, there enemies , npcs in games made canvas move faster framerate right?

you should divide rendering , update mechanisms, link seems helpful http://android-er.blogspot.com/2010/05/android-surfaceview.html

p.s blog doesn't belong me neither related it


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -