Well, I almost have it. I really need some help now, I figured it out mostly, but now I'm clueless.
BTW, I know I won't get much improvement doind this on a menuScreen, I'm just trying to figure it out before applying this to the playscene loading process.
I'm using version 0.99.1 I believe, I prefer not to change versions till the project is done..just in case.
//This will also load MenuAtlas.png on the TextureCache.
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"MenuScene/MenuAtlas.plist"];
//Create the SpriteSheet and add it as a child (to the Layer)
CCSpriteSheet *menusheet = [CCSpriteSheet spriteSheetWithFile:@"MenuScene/MenuAtlas.png"];
[self addChild:menusheet];
//Now every sprite you create from that Atlas(MenuAtlas.png) has to be added as a child to the Spritesheet
//Adventure button
CCSprite * adventurebttn = [CCSprite spriteWithSpriteFrameName:@"adventure_1.png"];
[menusheet addChild:adventurebttn];
//Time button
CCSprite * timebttn = [CCSprite spriteWithSpriteFrameName:@"time_1.png"];
[menusheet addChild:timebttn];
//Score button
CCSprite * scorebttn = [CCSprite spriteWithSpriteFrameName:@"scores_1.png"];
[menusheet addChild:time2bttn];
//and every other sprite that is on that Atlas.
//After loading all the menu Items I create the menu as this, using as sprites the previous ones from the atlas added to the //SpriteSheet
CCMenuItemImage *newGameButton = [CCMenuItemImage
itemFromNormalSprite:adventurebttn
selectedSprite:adventure2bttn
target:self
selector:@selector(NewGame:)];
But I get a black screen and an error:
*** Assertion failure in -[CCSprite draw], /Users/AlbertoSendra/Desktop/ZCupxDv2/libs/cocos2d/CCSprite.m:493
*** Assertion failure in -[CCSprite draw], /Users/AlbertoSendra/Desktop/ZCupxDv2/libs/cocos2d/CCSprite.m:493
*** Assertion failure in -[CCSprite draw], /Users/AlbertoSendra/Desktop/ZCupxDv2/libs/cocos2d/CCSprite.m:493
and keeps appearing on the console till I stop the task.
that line in CCSprite says:
NSAssert(!usesSpriteSheet_, @"If CCSprite is being rendered by CCSpriteSheet, CCSprite#draw SHOULD NOT be called");
I suppose something I've done wrong creating the spritesheet and adding It's child that confuses cocos2D when calling rawing, so nothing ends up showing
after reading this post: http://www.cocos2d-iphone.org/forum/topic/7830#post-47584
I guess there's a problem with parenting using sprites from an spritesheet in the menu buttons??
Maybe because the itemFromNormalSprite:adventurebttn method calls the draw function in CCSprite for drawing it, but being an spritesheet child it should call the textureatlas draw function? or something like that..