We have updated the
DrawThread to run at an arbitrary number of frames per second, adapting to the time required to render instead of a fixed 30 fps, and we are using sprites. Now is the perfect time to add a frames-per-second counter. It is a very easy tool and is also handy to check performance.
We could have used a
TextView, but there are some good reasons to draw it on the
Canvas directly instead:
SurfaceViewsuffers when we overlay other views on top of it
We will make a class named
FPSCounter that extends from
GameObject and looks like this:
public class FPSCounter ...