我的问题是有关使用CCSpriteBatchNode的是如何工作的...当你与一个文件初始化CCSpriteBatchNode,让我们说:的Cocos2D:CCSpriteBatchNode初始化
CCSpriteBatchNode *spriteBatch;
spriteBatch = [CCSpriteBatchNode batchNodeWithFile:@"file.pvr.ccz"];
[self addChild:spriteBatch];
然后,这里是我的疑问...为什么你需要添加你将使用的每个精灵到CCSpriteBatchNode,如果这些应该被加载,当你打电话batchNodeWithFile?
在这里你添加的每个精灵代码:
NSArray *images = [NSArray arrayWithObjects:@"sprite1.jpg", @"sprite2.jpg", @"sprite3.jpg", @"sprite4.jpg", @"sprite5.jpg", @"sprite6.jpg", nil];
for(int i = 0; i < images.count; ++i) {
NSString *image = [images objectAtIndex:i];
float offsetFraction = ((float)(i+1))/(images.count+1);
CGPoint spriteOffset = ccp(winSize.width*offsetFraction, winSize.height/2);
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:image];
sprite.position = spriteOffset;
[spriteBatch addChild:sprite]; //Here is what I mean... Why to do this? Isn't that supposed that they are already loaded in the CCSpriteBatchNode?
}
谢谢!
谢谢!现在我明白了!我很困惑:P – Axort 2012-02-22 18:51:53