@interface GameplayLayer : CCLayer <GameplayLayerDelegate> {
CCSprite *vikingSprite;
SneakyJoystick *leftJoystick;
SneakyButton *jumpButton;
SneakyButton *attackButton;
CCSpriteBatchNode *sceneSpriteBatchNode;
}
@end
#pragma mark –
#pragma mark Update Method
-(void) update:(ccTime)deltaTime {
CCArray *listOfGameObjects =
[sceneSpriteBatchNode children]; // 1
for (GameCharacter *tempChar in listOfGameObjects) { // 2
[tempChar updateStateWithDeltaTime:deltaTime andListOfGameObjects:
listOfGameObjects]; // 3
}
}
需要更新的game object放到一个batchNode中,每帧通过children取出。而不需要持有每个对象。
[self scheduleUpdate];
Sets up a scheduler call that will f ire the update method in GameplayLayer.m on every frame.