Pretty much the title sums it up. After I transition to my game scene and set up a few sprites and get a scheduler going, my frames per second goes crazy and displays anything in between 30fps and 60fps. All I'm doing is calling an update method 60 times a second and all that the update method has in it is an NSLog statement. Here's my code:
-(id)init {
if( (self=[super init] )) {
isTouchEnabled = YES;
Sprite *battlefieldBackground = [Sprite spriteWithFile:@"prairieBattlefield.png"];
battlefieldBackground.position = ccp(160, 320);
[self addChild:battlefieldBackground];
Sprite *gameMenuBackground = [Sprite spriteWithFile:@"gameSceneMenuBackground.png"];
gameMenuBackground.position = ccp(160, 80);
[self addChild:gameMenuBackground];
AtlasSpriteManager *spriteAtlasManager = [AtlasSpriteManager spriteManagerWithFile:@"inGameActionsSprites.png"];
[self addChild:spriteAtlasManager];
AtlasSprite *upgradesIcon = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 64, 63) spriteManager:spriteAtlasManager];
AtlasSprite *radarIcon = [AtlasSprite spriteWithRect:CGRectMake(0, 63, 64, 63) spriteManager:spriteAtlasManager];
AtlasSprite *radioActiveIcon = [AtlasSprite spriteWithRect:CGRectMake(64, 0, 64, 63) spriteManager:spriteAtlasManager];
AtlasSprite *peaceIcon = [AtlasSprite spriteWithRect:CGRectMake(64, 63, 64, 63) spriteManager:spriteAtlasManager];
[spriteAtlasManager addChild:upgradesIcon];
[spriteAtlasManager addChild:radarIcon];
[spriteAtlasManager addChild:radioActiveIcon];
[spriteAtlasManager addChild:peaceIcon];
MenuItemSprite *upgrades = [MenuItemSprite itemFromNormalSprite:upgradesIcon selectedSprite:upgradesIcon];
upgradesIcon.position = ccp(120, 120);
upgrades.position = ccp(-40, -120);
MenuItemSprite *radar = [MenuItemSprite itemFromNormalSprite:radarIcon selectedSprite:radarIcon];
radarIcon.position = ccp(200, 120);
radar.position = ccp(40, -120);
MenuItemSprite *radioActive = [MenuItemSprite itemFromNormalSprite:radioActiveIcon selectedSprite:radioActiveIcon];
radioActiveIcon.position = ccp(120, 40);
radioActive.position = ccp(-120, -200);
MenuItemSprite *peace = [MenuItemSprite itemFromNormalSprite:peaceIcon selectedSprite:peaceIcon];
peaceIcon.position = ccp(200, 40);
peace.position = ccp(40, -200);
Menu *menu = [Menu menuWithItems:upgrades, radar, radioActive, peace, nil];
[self addChild:menu];
[self schedule:@selector(update:) interval:1.0f/60.0f];
}
return self;
}
#pragma mark -
#pragma mark Game Loop
-(void)update:(ccTime)aDelta {
}
So my concern is if just an NSlog makes my performance dive that much, what will sprites do to my performance? I just want to make sure I'm not missing something now before I go and do a bunch of work on my game loop.
If anyone has some insight on this I'd appreciate it!