Change max fps

49 views
Skip to first unread message

Nitneroc

unread,
Apr 11, 2012, 3:40:01 PM4/11/12
to cocos2d discuss
This sounds a bit stupid, but I couldn't find a way to change the fps
limit. I read somewhere how to do it for pyglet, but it did'nt seem to
work in cocos2d.

Is there any way to do so ?

claudio canepa

unread,
Apr 11, 2012, 11:30:29 PM4/11/12
to cocos-...@googlegroups.com

--
 

This was feasible with pyglet 1.1.4, but seems to not work with pyglet 1.2dev.

Tested by modifying the test_sprite.py in cocos by  
"""
director.init()
pyglet.clock.set_fps_limit(30)
director.show_FPS = True
"""
You can toogle  the display of fps in cocos by pressing ctrl-x

In windows, pyglet 1.1.4 somehow tries to comply; with 1.2 dev it goes full tilt.

In theory, you can have the following fps locking status in pyglet, with or without cocos:

no locking:
(passing vsync=False when creating the Window in pyglet  or  passing vsync=False when calling  director.init() in cocos)
You get  the maximun frame rate your system can deliver

locking to vertical retrace: with vsync=True , which is the default, you get the same framerate as your monitor refresh rate

locking to a specific value:
import pyglet.clock
pyglet.clock.set_fps_limit(limit)

Note: you need to have at least one scheduled function, even if it does anything, or the framerate drops to aprox 14 fps

Nitneroc

unread,
Apr 12, 2012, 3:53:20 PM4/12/12
to cocos-...@googlegroups.com
Thank you very much for this perfect answer. I should have thought this had to do with vsync !
Reply all
Reply to author
Forward
0 new messages