Coding the Hud
The HUD in this game is no more complex than the previous game. We will define some Rect
instances to draw the controls on the screen, we will rely on GameState
to provide the time and fastest times for each level and we will make the button Rect ArrayList
available so that GameEngine
can pass then them to our two classes that require them to handle the player's input.
Get started by adding a new class called HUD
and add the following members and constructor method.
import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import java.util.ArrayList; class HUD { private Bitmap mMenuBitmap; private int mTextFormatting; private int mScreenHeight; private int mScreenWidth; final float ONE_THIRD = .33f; final float TWO_THIRDS = .66f; private ArrayList...