Iphone – Layer vs Scene in Cocos2d for iPhone game development

cocoa-touchcocos2d-iphoneiphone

Using cocos2d for iPhone game development, I am confused between Layer and Scene.
For example, My simple game have several "UI Pages" like main menu, highscores, game board etc.

So should I use Layer or Scene for every "UI page", and why?

Best Answer

Reviewing SpritesDemo.m/.h, it would appear that they are using Layer, and then creating new scenes, attaching the layer and then replacing the scene on the director

@interface SpriteDemo : Layer
@interface SpriteManual : SpriteDemo

The code then does the following:

-(void)nextCallback:(id)sender {
  Scene *s = [Scene node];
  [s add: [nextAction() node]];
  [[Director sharedDirector] replaceScene s];
}

So, in short, the answer to your question would be "both", you use Layer to represent your actual "UI Page", but you attach the Layer to a new scene and replace the current scene in the director.

Related Topic