Everything looks good, and I tried out your sample code to be sure, and it updates fine. The only difference from my code and yours is that I overrode the constructors as such and dropped your view into a layout:
public class Game extends View {
private Bitmap enemy;
private Paint dpaint;
private float x, y;
public Game(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
enemy = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
enemy = Bitmap.createScaledBitmap(enemy, 300, 300, false);
dpaint = new Paint();
x = 0;
y = 0;
}
public Game(Context context, AttributeSet attrs) {
this(context, attrs, 0);
// TODO Auto-generated constructor stub
}
public Game(Context context) {
this(context, null);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(enemy, x, y, dpaint);
Log.d("GAME", "REDRAWN");
}
@Override
public boolean onTouchEvent(MotionEvent event) {
x = event.getX();
y = event.getY();
invalidate();
return true;
}
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.example.gametest.Game
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>