I've done a few cocos2d tutorials and have the very basics down, I think. I was wondering if someone can help me out and point me to somewhere I can learn about game structure within cocos2d? So far, I've just been setting up the game scene in applicationDidFinishLaunching method in the app delegate. Am I supposed to pass the reference to the scene from method to method? Is there a better way? Thanks for reading.
Game Structure with cocos
(5 posts) (5 voices)-
Posted 2 years ago #
-
in my game i have one class called
GameMasterwhich holds references to all the scenes in my game as class fields. I also retain these scenes so that i can use them later on again without creating them from scratch.The only purpose of this class is to switch between different modes of my game.
That's it. The scenes i create are custom classes which inherit fromSceneand i pass them a reference ofGameMasterso that they can call methods likemainMenuorgameOveron it. These methods (inGameMaster) then switch between the scenes.In other words: the master knows about scenes but not about the actual game logic and every scene knows about itself and about game states but not actual about what other scenes exist.
This class design has worked out pretty well for me so far.
Hope that helps you.Posted 2 years ago # -
I am interested in this. Could you post a simple example of the project? thx
Posted 2 years ago # -
You need to look at design patterns, start with Singleton :-)
Posted 2 years ago # -
Hello i have also this kind of thought that You need to look at design patterns, start with Singleton.
Posted 2 years ago #
Reply
You must log in to post.