Should I use Canvas or SurfaceView for a chess game?

by Dan Sherman » Sun, 11 Oct 2009 07:27:44 GMT

Sponsored Links
 SurfaceView can be either run with a Canvas front-end, or an OpenGL frontend
(which I think was your question).

For a chess game, you're most likely going to be just fine with Canvas.  You
won't really need OpenGL until you have 50-100 sprites on the screen moving
quite quickly :)

- Dan


Other Threads

1. Trouble redrawing a View, using OnKeyListener, onDraw and invalidate.

The green plane is shown on the golden-brown surface but when I press
a key nothing happens.
I want eventually be able to move the plane pressing 4 different keys
+ another one for shooting but that's easy if I can just get the thing
moving in the first place.
When I press a key in the emulator, nothing happens at all.


import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.KeyEvent;
import android.view.View.OnKeyListener;

public class Shmup extends Activity { //GraphicsActivity {

    protected void onCreate(Bundle savedInstanceState) {
        setContentView(new GameView(this));

    private static class GameView extends View implements
OnKeyListener {
        private Paint mPaint = new Paint();
        private int x;
        private int y;

        public GameView(Context context) {
            x = 135;
            y = 303;

        @Override protected void onDraw(Canvas canvas) {
            Paint paint = mPaint;
            canvas.translate(10, 10);

        @Override public boolean onKeyDown(int keyCode, KeyEvent
event) {
//              if (keyCode == KeyEvent.KEYCODE_M) {
//                      x = 145;
//                      y = 100;
//                      this.invalidate();
//              }
                x = 145;
                y = 100;
                return true;

        public boolean onKey(View v, int keyCode, KeyEvent event) {
                x = 145;
                y = 100;
                return true;




2. Trouble migrating apps to 1.5


is anyone else having trouble with the new app running 'system'? My
emulator just ignores them, can't launch any app. Changed the project
build target to 1.5 and made sure my AVD is 1.5 too.

If i run once, when the emulator isn't started, after it starts it has
no error message (and does nothing). Then, every time i try to run the
app it says "emulator: ERROR: the user data image is used by another
emulator. aborting". I'm sure i must be doing something wrong, but i
can't figure it out :) Any help is appreciated...


3. Some Probleme with Tic Tac Toe

4. Suggestion for 1.5 Error message regarding SD Card

5. Widgets - use (any) subclassed Views?

6. AnimationDrawable help request

7. Question regarding detecting view for touch event.