我正在尝试使用巴里班创建一些带有图像和标签的菜单项
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];如果CCSprite由CCSpriteBatchNode呈现,则不应调用CCSprite#draw是在日志中显示的错误
我知道除了CCSprites之外,我不能向CCSpriteBatchNode添加任何其他对象,但是如何处理这种情况呢?
发布于 2012-03-28 11:52:55
尝试使用spriteWithSpriteFrameName
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"myAtlas.plist"];
CCSprite *normalMenuItemSprite = [CCSprite spriteWithSpriteFrameName:@"menuItem.png"];https://stackoverflow.com/questions/9888856
复制相似问题