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 ?
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).
I think that with you 2nd sample, I can do what I need.
thanks a lot !
On Feb 10, 3:22 pm, claudio canepa <
ccanep...@gmail.com> wrote:
> On Fri, Feb 10, 2012 at 4:27 AM, Philippe <
philippe.cr...@gmail.com> wrote:
> > I could probably pass datas from my thread to my Sprite using a Queue.
>
> But actually, that thread owns the datas for all my layers and> sprites.
> > And the datas are updated by a distant application (UDP)..
> > I do not think that the queue could be shared between all my
> > cocosnodes.
>
> I was thinking the UDP thread updating data to a model in the main thread,
> model an EventDispatcher that further updates all the parts in the view.
>
> To that end I mixed a bit of [1] and [2] to get a script with a fake app
> not using pyglet-cocos: a simple main loop which also manages to get data
> from other thread. See pastebinhttp://
pastebin.com/ucMsUCEN
>
> Then I wanted to replace the fake app with a cocos app; essentially
> adapting the pump function
>
> Whitout using MVC the thing would be shorter, but seems that you have a
> model in your app. So, using the Tetrico [0] style of MVC and bits of your
> first code I wrote a second script where the UDP thread sends data to a
> queue, a Controller layer in the main thread moves that data to the model ,
> from were it founds its way to the view.
>
> All very rought, and I'm sure it can be vastly improved
> See at your own risk athttp://
pastebin.com/N45vUa8w
>
> [0]
http://code.google.com/p/los-cocos/source/browse/#svn%2Ftrunk%2Fsampl...