Here is code how to start a specific application component:
- (void)viewDidLoad {
[super viewDidLoad];
/* Link application to ios view */
UIAppComponent->pExtension = IOSViewComponent;
/* Link ios view to engine */
IOSViewComponent->pExtension = MyGameComponent;
/* Start the application and set up the view handle */
self.view = (id) IOSViewHandle(IOSViewCast(UIAppStart()));
}
The second line links the IOS platform specific implementation to the application engine.
The third line links the game component to the IOS platform.
The fourth line starts the application and links the view to the controller.
Neither the application component or the game are aware of the platform it is running on.
And the platform does not know what game is running.
This is a separation of concerns and allows me to port code to run on the mac and then run it on the simulator without having to modify the game code itself in any way.
Note that the application component creates the object and does not need to be passed the platform or game to run. It all works behind the scenes and that is the way it should be done.
No comments:
Post a Comment