Sunday, June 10, 2012

Building a view and controller layer

1-800-PetMeds
Building a view and controller layer: Hey all. I am considering how I want to handle the view and controller layers of my game engine, and I just wanted to get some opinions on my thought process. I have been working a lot with iOS lately, and I have come to really like their model for views and controllers. For those who dont know, the way views and controllers work in iOS is that the UI is controlled by UIViewControllers. Each UIViewController has one root view, and an unlimited hierarchy of subviews can be created and added as children to the root view. The UIViewController is responsible for building the view, and making the calls to render the view, as well as the option of handling events on its view (the UIView can also handle its own events).



My question is, does this seem like a good logical base for a game engine as well? Each "View" in the game, such as the main 3d scene, the options panel, the login screen, each of these would have a GameController, and attached to each GameController would be a root GameView. Each GameController builds its subviews, and then the root view of the controller is added to the root GameController's view, which is essentially just a root node. Then on each render pass, the view hierarchy is traversed, and each view is rendered.



Not sure if this is making sense by this point, but if you're still with me, I'm wondering if there is anything that is obviously wrong with this architecture, whether its something small or big. I'd appreciate any opinions on the matter, and if there are any questions I will be happy to clarify.
1-800-PetMeds

No comments:

Post a Comment