4

Quite a broad question. I'm looking to refactor an existing game app so that we have a base framework for games, which are extended with some kind of modular plugin architecture. So we have:

GameCore - lots of base classes, etc. GameBundle A/B/C... - bundles with lots of subclasses of those in the core, along with lots of resources

The game won't function at all without a concrete bundle which implements the game itself. In theory it would also be possible to break down these bundles further and mix and match. This is a very appealing design.

Using NSBundle seems to be the neatest solution, but I'm hitting some snags: The code in the GameBundle must be linked with the GameCore or it won't compile, but then when the GameCore code is loaded from the NSBundle, you get duplicates of all the core classes. This suggests that I'm way off the mark with how I'm approaching this!

This could easily be implemented with static libs, but then it's not possible to easily include resources...

So, could anyone suggest a workable architecture that would do as I wish? To summarise;

Abstract game core Indeterminate number of GameBundles added to the target, which are (ideally) loaded dynamically at runtime.

Hope someone can help!

Jonathan Crooke
  • 912
  • 7
  • 19
  • I've actually done this before using `NSBundle` where each bundle was a new `xib` that would be instantiated using `initWithNibName:bundle` and then displayed with `pushViewController`. You could probably accomplish what you want using a similar strategy however I'm not entirely sure how to do it with your particular situation. Are you just trying to load extra code? If you want a mutli-game architecture then you could just do what I did and push the new game as a new viewController. – Drew Mar 23 '12 at 18:34

0 Answers0