final SurfaceView surf = (SurfaceView)findViewById(R.id.surface_home);
surf.setOnTouchListener( new SurfaceView.OnTouchListener(){
private boolean moving = false;//stupid state
public boolean onTouch(View v, MotionEvent event) {
switch( event.getAction() ){
case MotionEvent.ACTION_DOWN:
final int x = (int)event.getX();
final int y = (int)event.getY();
final Rect bounds = mTiles.getBounds();
moving = bounds.intersects(x, y, x+1, y+1);
return true;
case MotionEvent.ACTION_MOVE:
if( moving ){
final int x_new = (int)event.getX();
final int y_new = (int)event.getY();
mDrawTiles.draw( new DrawLogic(){
public void draw(Rect _surface) {
mTiles.setBounds(
x_new - mDrawWidth/2,
y_new - mDrawHeight/2,
x_new + mDrawWidth/2,
y_new + mDrawHeight/2);
}
});