更新时间:2023-02-26 22:23:01
见的如何做这种的博客文章。你需要看看 SurfaceView 和的 onTouchListener 。从博客摘自:
See this blog post on how to do it. You need to look at SurfaceView and the onTouchListener. Taken from the blog:
surf.setOnTouchListener( new SurfaceView.OnTouchListener(){
public boolean onTouch(View v, MotionEvent event) {
case MotionEvent.ACTION_MOVE:
if( moving ){
final int x_new = (int)event.getX();
final int y_new = (int)event.getY();
mDrawTiles.draw( new DrawLogic(){
@Override
public void draw(Rect _surface) {
mTiles.setBounds(
x_new - mDrawWidth/2,
y_new - mDrawHeight/2,
x_new + mDrawWidth/2,
y_new + mDrawHeight/2);
}
});
}