Stephen
Stephen

Reputation: 499

Cocos2d CCScene & CCLayer setup

Sorry for the newbie question but I was wondering what the difference is between these two different setups for the scene & the layer? I have tried both ways and each one works but I just don't know what the difference is or which one I should use.

@implementation Game

+(id) scene {
CCScene *scene = [CCScene node];
[scene addChild:[Game node]];
return scene; }

Or this way.

@implementation Game

+(id) scene {

CCScene *scene = [CCScene node];
Game *layer = [Game node];
[scene addChild:layer];
return scene; }

Upvotes: 0

Views: 631

Answers (1)

Yannick Loriot
Yannick Loriot

Reputation: 7136

I don't see any difference between your 2 sample of code. Your 2 methods are identically the same.

[Game node] returns a layer so in the first case you add it directly into your scene and in the 2 example you just put it into a variable then add it into your scene. For the compiler this is the same thing here.

Upvotes: 1

Related Questions