我的環境中有四種不同類型的對象(box2d),每種類型的對象都有自己的多個實例,並且希望找到最有效的方式來處理添加和操作所有CCSprites。精靈都來自不同的文件,所以最好創建每個精靈並將其添加到數據結構(NSMutableArray),或者即使每個CCSprite文件都不同(對於每種類型的對象),我會使用CCSpriteBatchNode嗎?謝謝。處理多個CCSprites的最有效方法?
@interface LevelScene : CCLayer
{
b2World* world;
GLESDebugDraw *m_debugDraw;
CCSpriteBatchNode *ballBatch;
CCSpriteBatchNode *blockBatch;
CCSpriteBatchNode *springBatch;
CCSprite *goal;
}
+(id) scene;
// adds a new sprite at a given coordinate
-(void) addNewBallWithCoords:(CGPoint)p;
// loads the objects (blocks, springs, and the goal), returns the Level Object
-(Level) loadLevel:(int)level;
@end
感謝您的回覆@phooze,它很好地知道我可以通過兒童參考訪問任何對象。我添加了一些代碼來清除我的問題。我在想的是每個有多個精靈的對象都有一個獨立的CCSpriteBatchNode,因爲它會降低OpenGL調用。 – SteveWight 2011-02-08 07:36:18