Coding the GameObjectSharer class
This class will have two pure virtual functions that share GameObject
instances with other classes.
Create a new header file in the Header Files/FileIO
filter called GameObjectSharer.h
and add the following code:
#pragma once #include<vector> #include<string> class GameObject; class GameObjectSharer { public: virtual std::vector<GameObject>& getGameObjectsWithGOS() = 0; virtual GameObject& findFirstObjectWithTag( std::string tag) = 0; };
The getGameObjectsWithGOS
function returns a reference to the entire vector of GameObject
instances. The findFirstObjectWithTag
function returns just a single GameObject
reference. We will see how we implement these functions when we inherit from GameObjectSharer
when we code the LevelManager
class next.
Briefly, before the LevelManager
class, create a new...