figured It would be better than starting a new topic.
I understand differences between Scenes and Layers, but I'm new in programming , so I would like to know best practices for a couple of things.
In my game I have the Menu Scene, Where I preload an AtlasSprite (wich contains all my main menu art) and load from It the mainmenu background, and then I call the Layer
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"MenuScene/MenuAtlas.plist"];
NSString * menubgframeName = @"menu_background.png";
CCSprite *bg = [CCSprite spriteWithSpriteFrameName:menubgframeName];
bg.position = ccp(160,240);
[self addChild:bg z:0];
[self addChild:[MenuLayer node] z:1];
On the Layer, I crate the Menu with the buttons using art from the AtlasSprite
// Create and add menu buttons
NSString * menuadventureframeName = @"adventure_1.png";
NSString * menuadventure2frameName = @"adventure_2.png";
CCSprite * adventurebttn = [CCSprite spriteWithSpriteFrameName:menuadventureframeName];
CCSprite * adventure2bttn = [CCSprite spriteWithSpriteFrameName:menuadventure2frameName];
CCMenuItemImage *newGameButton = [CCMenuItemImage
itemFromNormalSprite:adventurebttn
selectedSprite:adventure2bttn
target:self
selector:@selector(NewGame:)];
NSString * menutimeframeName = @"time_1.png";
NSString * menutime2frameName = @"time_2.png";
CCSprite * timebttn = [CCSprite spriteWithSpriteFrameName:menutimeframeName];
CCSprite * time2bttn = [CCSprite spriteWithSpriteFrameName:menutime2frameName];
CCMenuItemImage *timeAttackButton = [CCMenuItemImage
itemFromNormalSprite:timebttn
selectedSprite:time2bttn
target:self
selector:@selector(TimeAttack:)];
…..
…
// Create the menu
CCMenu *menu = [CCMenu menuWithItems: newGameButton,timeAttackButton,scoresButton,helpButton, nil];
menu.position = ccp(160,170);
[menu alignItemsVerticallyWithPadding:0.0];
[self addChild: menu z:0 tag:tMenu];
Each selector calls a method wich bassically plays a sound ( previously preloaded) and replace the scene
-(void) Scores: (id) sender
{
NSLog(@"Scores");
[[SimpleAudioEngine sharedEngine] playEffect:@"Sound/Effects/Next_mod.mp3"];
[[CCDirector sharedDirector] replaceScene:[ScoresScene node]];
}
And there I do pretty much the same, on the scene I load the background and call the layer, and on the ScoreLayer load all the art
So, questions:
Is this the right way of doing things?
Should I load the background on the scene, and then the rest on the layer, or everything on the Layer?
Should I just have the one scene (menu scene) and the rest be different Layers (not scene+Layer)
The AtlasSprite, If I load it on the mainmenu scene, it is available throught the all the others scenes right?
If each time I do [[CCDirector sharedDirector] replaceScene:[whatever node]]; it gets cleared than maybe I should just do one scene, and the scores, help, info options from the menu be new Layers instead of new scenes?