1
votes

Hi all writing an app for iphone using cocos2d and objective c. i have my frame rate set at 30 fps with [[CCDirector sharedDirector] setAnimationInterval:1.0/30]; this is fine for awhile but at 1 point in the app the frame rate increases to between 60-90 fps on simulator when swapping between 2 scenes. i put a break point in to get the animationInterval value and it always says it is 0.033 so why would the frame rate be spiking like this? i have been using [[CCDirector sharedDirector] stopAnimations]; and [[CCDirector sharedDirector] startAnimations]; when swapping layers and scenes but i always reset the the interval value when i start it again. any help would be appreciated thanks

this is the exact point when the fps goes nuts. when the gamescene is loaded

[[CCDirector sharedDirector] stopAnimation];
GameScene *gameScene = [GameScene node];
[[CCDirector sharedDirector] replaceScene:gameScene];
[[CCDirector sharedDirector] startAnimation];
[[CCDirector sharedDirector] setAnimationInterval:1.0/30];
1
The spike in the frame rate is because you are making both scenes 30 fps. When they play together you'll get 60+ fps. The interval is telling you .033 because that is still 30 fps, but with only one animation. If you play with that 30, and switch it to 15, you should see that when you are swapping between front and back buffers or screens that you are getting around 30 fps. - Jim
that was exactly my problem thank you very much - glogic

1 Answers

0
votes
CCDirector *director = [CCDirector sharedDirector];
[director setAnimationInterval:1.0/60];
[director setDisplayFPS:YES];

Try this to get the exact interval in frames.