Thanks again for you explaination. I understand better your sample. One layer using schedule() to check messages works !
In my application, I do not have particles. But I have some actions (FadeIn, MoveBy, ...) About your queue, then, it depends on how fast it gets filled by the UDP thread. Seems a better idea to empty it (or try to) at each call of the scheduled function. But should hope for a fast schedule, and slower UDP anyway :) On Feb 12, 9:51 pm, claudio canepa <[email protected]> wrote: > On Sun, Feb 12, 2012 at 8:13 AM, Philippe <[email protected]> wrote: > > snip > > > > > > > > > > > something like this, will wait, using no CPU, most of the time > > and sometimes, will get something out of the queue and process it. > > > > t = threading.Thread(target=check) > > > def check(): > > > running = True > > > while running: > > > msg = my_queue.get() > > > if msg == 'stop': > > > runnning = False > > > else: > > > process_msg(msg) > > > but, it's in a thread :/ > > > I am not a specialist, so maybe, this is not correct ! > > but it's what I think... > > The choice depends on your application style: > > Style 1: highly static, meaning no animations, particles. Basically the > view only changes in response to UDP messages. > There your use of a *blocking* get may work, because no message implies no > changes in the view. > But blocking the main thread can have side effects with the pyglet > scheduling, and add lag to the response of local controllers (keys, mouse) > > Style 2: you want smooth animations, maybe particles. > Non blocking would be my choice here: you give the main thread the most of > CPU available, a more smooth time flow, and not mess pyglet timings. > > > Thank you for your explanation of pyglet FPS. It's clear to me now. > > Still, I do not find how to emit a event that will redraw my window,> or part > of it. > > Your code with use of schedule() is the best solution so far. > > > I feel sad to not be able to simply refresh the objects that need to, > > based on an event (instead of checking periodically). > > I will search little but more ! > > Roughly, the standard for Open GL drawing is to redraw all the screen at > each frame, > Partial refreshes are hacks or stunts. > > -- > 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.
