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.graphics.PointF;
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, 
                ge, 
                pixelsPerMetre);
    }

First, be aware of the two ...

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

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