On Sat, Feb 11, 2012 at 12:12 PM, Philippe <[email protected]> wrote:
> nice help ! thank you. > > about the queue, personally, I use the thread safe Queue.Queue() > http://docs.python.org/library/queue.html#module-Queue > > then, something like that > while running: > msg = my_queue.get(True, 0.1) > > no need of threading.Lock() like that. > > I checked the schedule function you used in the GameCtrl (line 65). > from the doc "Schedule a function to be called every frame" > What does it mean "every frame" ? > Is there a fix framerate in cocos2D ? > > While starting the window with director.init(...) you can pass a kw-param vsync = True / False Default is True, which means pyglet will try to synchronize with the vertical retrace. But, if your code don't have any schedule() call, it will try to spare battery and cpu / gpu , thus calling about 10 times per second. You can see the actual fps with director.show_FPS = True > I will try to do like above (in a thread): while running: msg = my_queue.get(True, 0.1) > meaning that it waits all the time, and sometime get something from > the queue. > the 0.1 means that it will not wait for ever anyway. then, if > runnning==false, the thread will exit (simple way to close the > application). > Why not get with try: msg = my_queue.get(False) except Queue.Empty: return # process message This way you don't spend time waiting in an empty queue > I think that with you 2nd sample, I can do what I need. > thanks a lot ! > Glad No doubt you will find some interesting things with threading + pyglet, consider to take notes and blog / post somewhere your findings -- claudio -- You received this message because you are subscribed to the Google Groups "cocos2d discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cocos-discuss?hl=en.
