The object specifications
Now we know that all our game objects will be built from a selection of components. Sometimes the components will be unique to a specific game object but most of the time the components will be used in multiple different game objects. We need a way to specify a game object so that the factory class knows what components to use to construct each one.
First, we need a parent specification class from which all the other specifications can derive so we can use them all polymorphically and not have to build a different factory or different methods within the same factory for each type of object.
Coding the ObjectSpec parent class
This class will be the base/parent class for all the specification classes. It will have all the ...
Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.