Coding the LevelManager class

We are nearly there. Coding this class will leave us with an executable project!

Create a new class called LevelManager and add the following members and the constructor.

import android.content.Context;
import android.util.Log;

import com.gamecodeschool.platformer.GOSpec.*;
import com.gamecodeschool.platformer.Levels.*;

import java.util.ArrayList;

final class LevelManager {

    static int PLAYER_INDEX = 0;
    private ArrayList<GameObject> objects;
    private Level currentLevel;
    private GameObjectFactory factory;

    LevelManager(Context context, 
                 GameEngine ge, 
                 int pixelsPerMetre){
        objects = new ArrayList<>();
        factory = new GameObjectFactory(context, 

First, be aware of the two ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.