• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps SurfaceView

oriz

Newbie
Main activity calls to game view:
Code:
gameview = new GameView(this,10,10); setContentView(gameview); gameview.setOnTouchListener(this);

gameview constructor
Code:
public GameView(Context context,float x ,float y) { super(context); holder = getHolder(); this.x=x; this.y = y; bmp = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher); t = new Thread(this); t.start(); }

The draw and the thread
Code:
public void draw() { c = holder.lockCanvas(); c.drawColor(Color.GREEN); c.drawBitmap(bmp,x,y,null); x=x+1; y=y+1; holder.unlockCanvasAndPost(c); } @Override public void run() { while(run == true) { if (!holder.getSurface().isValid()) continue; draw(); } }

Hey i started learning about game developing and i saw that i should do it with surfaceview
so i did an simple code that creates bitmap and move it but it takes it too much time to load!
when i start the app it somtimes shows white screen for like 7 seconds and only then loads..

what can be the problem?
The code is up
 
Back
Top Bottom