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