Layer vs Scene in Cocos2d for iPhone Game Development

Using cocos2d to develop an iPhone, I got confused between Layer and Scene. For example, in my simple game there are several “user interface pages”, for example, the main menu, high scores, game boards, etc.

So should I use Layer or Scene for each “user interface page” and why?

+5
source share
3 answers

Looking through SpritesDemo.m / .h, it looks like they are using Layer and then creating new scenes, attaching this layer and then replacing the scene with the director

@interface SpriteDemo : Layer
@interface SpriteManual : SpriteDemo

Then the code performs the following actions:

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

, , "", Layer " ", .

+4

:

CCLayer + scene, . " ", . " ".

( ) . , , . - . , , , + , .

, . . .

+2

, - ( Cocos2D, TouchEventsDelegate). , , , Cocos2D ( , ..).

0

All Articles