سؤال

I'm developing a game and inside I have a class called StageViewController. I noticed that code inside is becoming very very long and dull. In this class I have controller about gesture, position, animation and it's not easy use static class or singleton class to clean this class. Is a possible solution to use others viewcontrollers inside this StageViewController to simplify the code? Example: If in my game I should make an entry of an object that I should color, can I use another viewcontroller (with another class) to make my code inside StageViewController more simplify?

If you have any suggestion for me or link to read you can make me happy ;-)

هل كانت مفيدة؟

المحلول

Typically this indicates that you're storing model information in the view controller. The view controller should only keep track of how to display information. You should move the actual state of the game into model classes. These model classes inherit from NSObject, they are not view controllers.

In a well designed model-view-controller system, you should be able to run your entire game without knowing what the display looks like. Your model should be able to take inputs, update the game state, and provide outputs, regardless of how or whether that information is actually displayed. This kind of thinking improves reusability, and also reduces the complexity of your view controllers.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top