我的問題是有關使用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