2 Replies - 366 Views - Last Post: 08 April 2013 - 06:50 PM Rate Topic: -----

#1 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 159
  • Joined: 15-February 11

MVC question for a Cocos2D application

Posted 08 April 2013 - 12:17 AM

When trying to adhere to proper Model-View-Controller guidelines, where would I instantiate the Model when using a Cocos2D new Project in xcode. The project starts with 3 Classes: AppDelegate, HelloWorldLayer, and IntroLayer. It seems like AppDelegate is a Controller and that HelloWorldLayer and IntroLayer are views (although these two also have some element of controling the view as well (ie. onTouchesEnded...).

So I'm guessing to instantiate and initialize my GameModel (GameState) in AppDelegate? But I notice AppDelegate launches the IntroLayer using [director_ pushScene: [IntroLayer scene]]. Do I have to modify scene method parameters to take in GameState? This doesn't seem right...

What do you guys think?

Thanks for all your help in the last 24 hrs! :P

Is This A Good Question/Topic? 0
  • +

Replies To: MVC question for a Cocos2D application

#2 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 159
  • Joined: 15-February 11

Re: MVC question for a Cocos2D application

Posted 08 April 2013 - 12:43 AM

Also, I'm trying not to use global variables this is why I don't just do:

extern GameState *state;



But is this an instance where having a global variable accepted? I keep on reading that globals are so inelegant and that I should create a singleton and pass it around... what's the norm for a game state?
Was This Post Helpful? 0
  • +
  • -

#3 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: MVC question for a Cocos2D application

Posted 08 April 2013 - 06:50 PM

Post some code! There is no real norm or acceptable way per se. If you can justify however you organize your code then that is good enough reason.

Just be decisive with good reason.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1