[SOLVED] How to force screen update in main thread?

Hi everyone.

I’ve tried intensive processing from my Layer::init() method and the screen doesn’t reflect changes made there (I think I briefly get a non-responding pop-up from the Android launcher), I guess the thread in init is also the one that is responsible for updating the screen.

So when I load my next screen I want a busy-loading splash screen to take over, but I don’t want to handle the layer/scene transition in any thread but the event handler’s (I think you call this the main thread). As this is the thread that handles drawing, I would like to know the easiest way to force an immediate screen update from it.

It’s like this (force update?) but I’m not loading images. I guess I’ll have to got the long way and implement my work in a worker thread with awesome C++11 synchornisation.

Thanks in advance.

well, cocos2d-x isn’t spawning threads by default so if you want to do threading you need to implement it yourself. std::thread is a good choice. It surely takes a bit of learning. I started by building a thread pool as a singleton and spawning threads as needed. Then I am able to swap, reuse them, etc.

Okay, thanks @slackmoehrle, that answers my question. It’s so common to see games unresponsive while they load up or load a level for the first time. I presumed, given the async load image function and provision of progressTimer (which has no sense of time whatsoever!) that cocos2d-x would have this pattern covered already. Threads were easy to learn, there were accurate books on them… :frowning: Every day I’m in cocos2d-x I get about 3 new problems, reminds me of Bada., dem woz da Bad dayz lol

so you are saying that you got 99 problems but… :smile:

I feel ya. This is what programming is all about though. I’ve never not had anything to wrap my head around. I feel like given all the C++ there is to learn that I need to be constantly reading and practicing. Someday I might become amazing like a few of the developers we have here.

If you want I started a Google group called “Community C++” where we are all working together to get everyone up to speed on C++. It is a little slow right now as it is new, but the more the merrier.

Loving it. Think I fixed one more problem, what a feeling, it’s sooo obvious when you can see it. I think I just get hot and stressed before work and post all my problems for somebody else to stress about, or not. I like that I can learn this framework while not having to do more pointless “lab exercises”, no offence but the amount of toy projects in my portfolio has got me nowhere, I’ve got to feed my passion. I hope you don’t mind if I occassionally seek clarification here when it all gets too much for me. C++ is great, perhaps when I’ve got a bit more time I can delve into the cocos2d-x source, right now work and the threat of not having any take most of my time.