1
threaded surfaceview를 코딩했습니다. 그것은 작동하지만 잘 새로 고치는 것 같지 않습니다. 내가 잘 새로 고치지 않음을 의미하는 것은 EX입니다. EX : 마지막 위치에 그려지는 비트 맵 위치를 이동하면 + 새로운 것이됩니다.Android Threaded Surfaceview 새로 고침하지 않음
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;
}
} Screen 클래스 코드
:
{
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);
}
}
내가 Screen 클래스없이 노력이 충족 여기
내 코드입니다 hod 그러나 그것은 같은 일을한다. 화면을 지우기 위해 선이 누락 되었습니까?