I'd like to periodically log the framerate to the Debugger Console using NSLog() or similar. And I also want to show the amount of time that has elapsed since the scene became active (time since -onEnter, I guess). What exactly is the best way to do this?
How can I log the framerate (FPS) to the Debugger Console?
(5 posts) (4 voices)-
Posted 2 years ago #
-
Hi intelliot,
In your AppDelegate: [[Director sharedDirector] setDisplayFPS:YES];
If using current version it should be in applicationDidFinishLaunching.
hth.
Posted 2 years ago # -
That displays the FPS on the screen, but that's not what I'm looking for. I'd like the FPS to be periodically logged to the Debugger Console (the log messages you see in the console, which you can bring up with command+shift+r).
Part of the reason why I need to do this is because I have UIKit controls above my cocos2d scene, which cover the FPS display.
Also, what about the time elapsed in the current scene?
Posted 2 years ago # -
UIKit controls above your scene? Hmmm, in this case, shouldn't you pause the Director and so you will get only 4 fps anyway? If you don't pause it, the UIKit controls may seem unresponsive.
Anyhow, you can patch this in in Director in the method showFPS. Just do an NSLog every several hundred frames or so.
Posted 2 years ago # -
UIKit controls may only seem unresponsive if you're using the Fast/Threaded Director. The NSTimer director won't cause any problems with UIKit.
You have to edit the Cocos2d Source to make it log the FPS into Console every now and then. Not really recommended as it may cause a significant FPS drop. NSLog may be much slower than updating the FPS on screen...
Why don't you just move the FPS label into another location on screen? Still requires you to edit the Cocos2d source of course.
Posted 2 years ago #
Reply
You must log in to post.