Reputation: 2277
I'm trying to create some Menu Item with Image & Label, using barry's class
CGRect menuItemRect = CGRectFromString([[myAtlas objectForKey:@"menuItem.png"] objectForKey:@"textureRect"]);
CCSprite *normalMenuItemSprite = [CCSprite spriteWithBatchNode:batchNode rect:menuItemRect];
CCSprite *selectedMenuItemSprite = [CCSprite spriteWithBatchNode:batchNode rect:menuItemRect];
CCMenuItemLabelAndSprite *aMenuItem = [CCMenuItemLabelAndSprite itemWithLabel:itemLabel normalSprite:normalMenuItemSprite selectedSprite:selectedMenuItemSprite];
CCMenu *myMenu = [CCMenu menuWithItems:aMenuItem, nil];
myMenu.anchorPoint = ccpzero;
myMenu.position = ccp(330,280);
[myMenu alignItemsHorizontallyWithPadding:100];
[self addChild:myMenu];
If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called is the error that shows up in my log
I know that I can't add any others objects beside CCSprites to CCSpriteBatchNode but how can I deal with this situation ?
Upvotes: 1
Views: 332
Reputation: 26
Try using spriteWithSpriteFrameName
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"myAtlas.plist"];
CCSprite *normalMenuItemSprite = [CCSprite spriteWithSpriteFrameName:@"menuItem.png"];
Upvotes: 1