I use SurfaceView for my game, tried normal View first but that was to slow. Problem is, it still is. The redrawing just isn't anywhere fast enough for a game. So unless it is a lot faster on the real phone this won't cut it at all. Is it necessary to use OpenGL for games?
package com.android.shmup; import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.View; import android.view.KeyEvent; public class Shmup extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GameView(this)); } private static class GameView extends View { private Paint mPaint = new Paint(); private int x; private int y; public GameView(Context context) { super(context); x = 135; y = 303; setFocusable(true); requestFocus(); } @Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; canvas.translate(10, 10); canvas.drawColor(Color.rgb(184,134,11)); paint.setColor(Color.rgb(107,142,35)); paint.setStrokeWidth(1); canvas.drawRect(x, y, x+30, y+7, paint); canvas.drawRect(x+10, y+7, x+20, y+27, paint); canvas.drawRect(x+5, y+27, x+25, y+32, paint); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { y -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { x -= 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { y += 3; invalidate(); } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { x += 3; invalidate(); } return true; } } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---