Cocos2d: is it good practice to use a shared GameScene when having various levels?

Posted by mm24 on Stack Overflow See other posts from Stack Overflow or by mm24
Published on 2012-09-12T21:20:48Z Indexed on 2012/09/12 21:38 UTC
Read the original article Hit count: 224

In my code (based on the ShootEmUp example in this book, which I highly reccomend, source code in chapter 8 available here) I often use the trick of accessing the GameScene via:

+(GameScene*) sharedGameScene;

which returns a reference to the static instance of GameScene. Is a static instance of GameScene as in the book still a valid pattern in case I want a MainMenu calling GameScene initialized with different level data each time (e.g. different enemies)? (I have created a sceneWithId:(int) method where I load different level data each time.

Or should I pheraps create a GameScene class and then sublcass it?

E.g. FirstGameScene : GameScene 

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about static-methods