On Fri, Feb 10, 2012 at 4:27 AM, Philippe <[email protected]> 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 pastebin
http://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 at
http://pastebin.com/N45vUa8w

[0]
http://code.google.com/p/los-cocos/source/browse/#svn%2Ftrunk%2Fsamples%2Ftetrico

[1] http://www.tutorialspoint.com/python/python_multithreading.htm
[2] http://thread.gmane.org/gmane.comp.python.pyglet.user/2120


--
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.

Reply via email to