January 2016
Intermediate to advanced
304 pages
6h 17m
English
With the ability to attach and return components, let's get our first component built and added. We'll start with a simple one first. Currently, all objects have a position by default that's provided by the Object base class. Let's break this behavior into its own component.
Since we're converting an inheritance-based approach to a component-based one, the first task is to take the transform behavior out of the Object class. Currently, that consists of a single position variable and a function to both get and set that value.
Let's create a new class named TransformComponent and move this behavior into it, as follows:
#ifndef TRANSFORMCOMPONENT_H #define TRANSFORMCOMPONENT_H #include "Component.h" ...
Read now
Unlock full access