This article will be brief. If you have any questions about how to implement MVC in cocos2d in the previous articles, please tell me so that I can add more details. I (original author) recently took some very large outsourcing projects, so I didn't spend much time writing blogs. Here, I will briefly summarizeArticle:
- We have implemented the model, which can help us encapsulate the game logic, so that our focus is on the game logic, rather than other (such as rendering)
- We implemented the Controller to process user interaction and update the Model accordingly.
- We have implemented the view, and its responsibility is only to display the status of the model.
The interaction between the three is as follows:
- The Controller initializes the model and view.
- View is responsible for displaying Model
- View is responsible for receiving user touch events and passing them to the Controller for processing.
- The Controller implements the view proxy and can operate the model.
- The model executes some game logic processing and notifies the view of its state changes.
- View updates all objects in a model based on its current state, such as genie.
Leave a few open questions:
- If you want to use nsuodomanager to implement the "undo" function, where will you place this function? Model? Controller? View?
- How do you save the status information of the current scenario?
- Or can you add other questions?
Note: This article has been synchronously updated to the cocos2d MVC series.
If you think this article is helpful to you, please click the "recommendation" button next to it so that more people can see it and give me the motivation to write, thank you.