April 2017
Beginner to intermediate
394 pages
9h 16m
English
We need some way for our ParticleComponent to access this information. With that in mind, we will make use of the Factory design pattern that we learned about in Chapter 5, Decoupling Code via the Factory Method Pattern, and create a ParticleFactory class:
class ParticleFactory { public: static int objectCount; static std::map<ParticleType, ParticleSystem *> particleSystems; // Getting our Flyweight static ParticleSystem & GetParticleSystem(ParticleType type); ~ParticleFactory(); };
This ParticleFactory class is what we use to manage the creation of these Flyweights and to ensure that, if the object is already located in our map, we will return it. Otherwise, we will create a new object to be able to ...
Read now
Unlock full access