cocos2d-iphoneccspriteccmenuitem

Can I add a CCMenu with CCMenuItemSprite's to a spritebatchnode?


Can I add a CCMenu with CCMenuItemSprite's to a spritebatchnode?

As simple as that.

Code snippet:

-(void) setUpPauseMenu
{
    CCMenuItemSprite *p = [CCMenuItemSprite itemWithNormalSprite:[CCSprite spriteWithSpriteFrameName:@"emptyCircle.png"] selectedSprite:[CCSprite spriteWithSpriteFrameName:@"emptyCircle.png"] target:self  selector:@selector(pauseGameScene)];

    p.position = CGPointMake(50.0f, 440.0f);
    p.anchorPoint = CGPointMake(0.5f, 0.5f);

    //[spritebatchnodereference addChild:p];
    **//CAN I ADD p TO SPRITEBATCHNODE?** 

    CCLabelTTF *pauseText = [CCLabelTTF labelWithString:@"II" fontName:@"Marker Felt" fontSize:20];
    pauseText.position = CGPointMake(22.0f, 28.0f);
    pauseText.anchorPoint = CGPointMake(0.5f, 0.5f);
    [p addChild:pauseText];

    //Create pause menu
    CCMenu *pauseMenu = [CCMenu menuWithItems: p, nil];
    pauseMenu.anchorPoint = CGPointMake(0.5f, 0.5f);
    pauseMenu.position = CGPointMake(50.0f, 440.0f);
    pauseMenu.visible=TRUE;
    [self addChild:pauseMenu];

}

Solution

  • No.

    CCSpriteBatchNode only accepts CCSprite as children.