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 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.