Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Threaded Surfaceview Does not Refresh
    primarykey
    data
    text
    <p>I coded a threaded surfaceview. It works but does not seem to refresh well. What I mean by not refresh well is EX: If I move a bitmap position it continues to be drawn at is last location + is new one.</p> <p>Here is my code: </p> <pre><code>public GameView(Context context) { super(context); holder=getHolder(); currentScreen=new TestScreen(); currentScreen.Load(this.getResources()); } protected void Resume() { isRunning=true; renderThread=new Thread(this); renderThread.start(); } public void run() { while(isRunning) { gametime=lasttime-System.nanoTime(); lasttime=System.nanoTime(); if(!holder.getSurface().isValid()) continue; if(!(currentScreen==null)) { currentScreen.Update(gametime); Canvas cv=holder.lockCanvas(); currentScreen.Draw(cv, gametime); holder.unlockCanvasAndPost(cv); } } } public void pause() { isRunning=false; while(true) { try { renderThread.join(); } catch (InterruptedException e) { } break; } renderThread=null; } </code></pre> <p>}</p> <p>The Screen class code:</p> <p>{</p> <pre><code>public void Load(Resources resources) { square=BitmapFactory.decodeResource(resources, R.drawable.square); x=y=0; super.Load(resources); } @Override public void Update(long gametime) { x++; super.Update(gametime); } @Override public void Draw(Canvas cv, long gametime) { cv.drawBitmap(square, x, y, null); super.Draw(cv, gametime); } </code></pre> <p>}</p> <p>I tried without the Screen class method but it does the same thing. Am I missing some line to clear the screen?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload