Coding the Component base class
Create a new header file in the Header Files/GameObjects
filter called Component.h
and add the following code:
#pragma once #include "GameObjectSharer.h" #include <string> using namespace std; class GameObject; class Component { public: virtual string getType() = 0; virtual string getSpecificType() = 0; virtual void disableComponent() = 0; virtual void enableComponent() = 0; virtual bool enabled() = 0; virtual void start(GameObjectSharer* gos, GameObject* self) = 0; };
This is the base class of every component in every game object. The pure virtual functions mean that a component can never be instantiated and must always be inherited from first. Functions allow the type and specific type of a component to be accessed. Component types include collider, graphics, transform, and update, but...