我所拥有的:
我有 CustomView 类,我在其中打印Bitmap image;
一个point position;
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawBitmap(carSpriteImage, carspritePosition.x , carspritePosition.y, null);
}//end of OnDraw
我想 我想通过线程更新位置
public class AnimationHelperThread extends Thread{
CustomeView customeView;
public AnimationHelperThread(CustomeView customeView){
// TODO Auto-generated constructor stub
this.customeView=customeView;
}
@Override
public void run() {
super.run();
int x=0;
int y=0;
for(int i=0;i<1000;i++)
{
try {
Thread.sleep(400);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Point p=new Point();
p.set(x,y);
customeView.setCarspritePosition(p);
x+=1;
y+=2;
Log.i("Helper Thread", "Call "+i);
}
}
此方法无效,请给我建议