Code the Activity

This class is just like the one we have been coding for virtually the entire book. Take a look at the code and then add this class to your project.

import android.app.Activity; import android.graphics.Point; import android.os.Bundle; import android.view.Display; public class GameActivity extends Activity { GameEngine mGameEngine; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Display display = getWindowManager() .getDefaultDisplay(); Point size = new Point(); display.getSize(size); mGameEngine = new GameEngine(this, size); setContentView(mGameEngine); } @Override protected void onResume() { super.onResume(); mGameEngine.startThread(); } @Override protected void onPause() { super.onPause(); ...

Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.