Building the GameObjectFactory
It is the job of the GameObjectFactory to use the ObjectSpec based classes to assemble GameObject instances with the correct components.
Create a new class called GameObjectFactory and add the following members and constructor shown next.
class GameObjectFactory {
private Context mContext;
private PointF mScreenSize;
private GameEngine mGameEngineReference;
GameObjectFactory(Context c, PointF screenSize,
GameEngine gameEngine) {
this.mContext = c;
this.mScreenSize = screenSize;
mGameEngineReference = gameEngine;
}
}We have a Context object, a PointF to hold the screen resolution and a GameEngine object to hold a reference to the GameEngine class. In the constructor all these member variables are initialized. It is the Level class that will create and use a reference to this class. It is the GameEngine class that will create an instance of the Level class and supply the necessary references...