Here is an example (in my case, using Canvas) where in the game loop i
call the doDraw(Canvas canvas) to repeatedly paint the scene:
private long now;
private int framesCount=0;
private int framesCountAvg=0;
private long framesTimer=0;
private Paint fpsPaint=new Paint();
private void doDraw(Canvas canvas) {
// DO YOUR STUFF HERE
.....
// DRAW FPS:
now=System.currentTimeMillis();
canvas.drawText(framesCountAvg+"", 20, 20, fpsPaint);
framesCount++;
if(now-framesTimer>1000){
framesTimer=now;
framesCountAvg=framesCount;
framesCount=0;
}
}
Cheers!
Marcus.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en