Coding the GameObjectFactoryPlayMode class
Now, we will code our factory, which will construct working game objects from the GameObject
class and all the component related classes that we coded in the previous chapter. We will make extensive use of smart pointers, so we don't have to worry about deleting memory when we have finished with it.
Create a new header file in the Header Files/FileIO
filter called GameObjectFactoryPlayMode.h
and add the following code:
#pragma once #include "GameObjectBlueprint.h" #include "GameObject.h" #include <vector> class GameObjectFactoryPlayMode { public: void buildGameObject(GameObjectBlueprint& bp, std::vector <GameObject>& gameObjects); };
The factory class has just one function, buildGameObject
. We have already seen the code that calls this function in the previous code we wrote for the PlayModeObjectLoader
class. The function...